![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| delete comments | susau_79 | Shell Programming and Scripting | 10 | 08-03-2009 02:28 AM |
| how can i remove comments in random positions in a file?(bash) | bashuser2 | Shell Programming and Scripting | 2 | 05-02-2009 05:47 AM |
| AWK to skip comments in XML file | majormark | Shell Programming and Scripting | 1 | 10-29-2008 06:30 AM |
| Add Comments to the specifi lines i na file | ukatru | UNIX for Advanced & Expert Users | 1 | 09-21-2008 08:39 AM |
| removing comments from file | skully | Shell Programming and Scripting | 9 | 06-08-2008 09:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sed command to remove comments
Hello,
i am replying rather old post, but i have the similar problem with slight variation. when i use command: sed '/*,*/d' somefile.c suppose the file somefile.c contains line /* this is an example */ its removing comeplete line but when i have a line /* this is an example */ its removing only /* and */ and not the text between /* and */ i can easily implement the commad using command line arguments. but i want to know is there any command that deletes the entire characters present under /* and */ when they are in different lines. Thanks, |
|
||||
|
From http://sed.sourceforge.net/grabbag/t...t_with_sed.txt
Code:
!/usr/bin/sed -f
# if no /* get next
/\/\*/!b
# here we've got an /*, append lines until get the corresponding
# */
:x
/\*\//!{
N
bx
}
# delete /*...*/
s/\/\*.*\*\///
|
|
||||
|
If you are looking for a solution from other sed & awk then, look at CLOC.
CLOC -- Count Lines of Code |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|