Results 1 to 4 of 4
I am trying to use grep or sed to locate all nonblank lines that do not begin with a // /* or # in a file.
egrep ".+" will find ...
- 12-09-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 10
using grep or sed to find non blank lines not starting with ...
I am trying to use grep or sed to locate all nonblank lines that do not begin with a // /* or # in a file.
egrep ".+" will find all nonblank lines but I'm not sure about the rest
- 12-10-2009 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
This should work:
Code:egrep -v '(^//|^/\*|^#|^$|^[[:space:]]+$)'
- 12-10-2009 #3Just Joined!
- Join Date
- Oct 2009
- Posts
- 10
it works thanks
correct me if I'm wrong but the :space: isn't nescecary. Also why did you put it inside two sets of [] ? The ^$ already checks to see if a line is empty.
- 12-10-2009 #4Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
With [[:space:]] the outer brackets indicate a 'bracket expression', the [:space:] is the syntax to look for spaces and TABs.
The ^$ checks for an empty line. If the a line has only spaces or TABs (ie: [:space:]) in it it wouldn't match.


Reply With Quote