- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How i can delete one line in all my files?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2005 09:37 PM
тАО12-29-2005 09:37 PM
i'm do it to delete all the characters that are delimited by: /* any character */, in all my text files .How i can do it?
I'm in HP-UX .
Thanks.
Best regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2005 09:58 PM
тАО12-29-2005 09:58 PM
Solution%s/\/\*.*\*\///g
When you're happy it works, use "ed" to run this against all your files: -
for FILE in *.txt
do
ed $FILE <
w
q
EOF
done
(note the escaped $, this is so the shell doesn't interpret it)
This will remove everything between /* and */ on a line.
Note that this won't remove multi-line comments, but then your subject implies one line so I assumed this to be your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2005 09:59 PM
тАО12-29-2005 09:59 PM
Re: How i can delete one line in all my files?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-29-2005 10:33 PM
тАО12-29-2005 10:33 PM
Re: How i can delete one line in all my files?
1. Comments that cross lines:
/* Comment
* blah
*
*/
2. Comments that look like to be terminated
/* Don't do \*/ that here */
3. Other strangenesses
a = b*/*/*/*3/*/*/*3;
4. Unicode
/*├п┬╝ *├в *├в *├п┬╝ */
(contains 0uff0a 0u2215 and 0u2044)
If you use perl and install Regexp::Common, you can use Regexp::Common::comment, which should be safe for all of the above
http://search.cpan.org/~abigail/Regexp-Common-2.120/
http://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/Common/comment.pm
use Regexp::Common qw(comment);
while (<>) {
/$RE{comment}{C}/ and print "Contains a C comment\n";
}
use Regexp::Common qw(comment RE_comment_C);
while (<>) {
$_ =~ RE_comment_C () and print "Contains an C comment\n";
}
Enjoy, Have FUN! H.Merijn
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-30-2005 01:09 AM
тАО12-30-2005 01:09 AM
Re: How i can delete one line in all my files?
as procura brought Perl into play,
the removal of C comments seems such a common task that there already must exist dozens of solutions.
Probably overkill, but I remembered having come accross a parsing grammar for C comments in the POD of Damian Conway's Parse::RecDescent.
http://search.cpan.org/~tbone/Parse-RecDescent-FAQ-3.94/FAQ.pm#Removing_C_comments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2006 06:31 PM
тАО01-02-2006 06:31 PM