Re: regexp---remove comments---simplification
Colin Watson wrote:
>On Fri, Feb 21, 2003 at 07:18:48AM -0600, Gary Turner wrote:
[...]
>>
>> grep -v '^\ *#' some.conf | grep -v '^\ $' > condensed.file
>>
>> How would you combine these regexp's to remove a commented line (even if
>> indented) and a blank line? My various permutations and combinations
>> have resulted in errors.
>
>You'll want something like this:
>
> grep -v '^\( *#\| $\)' some.conf > condensed.file
>
>or:
>
> egrep -v '^( *#| $)' some.conf > condensed.file
Thanks. I wasn't escaping ()|. However as given, blank lines were not
deleted. grep -v '^\( *#\| *$\) or egrep -v ^( *#| *$) work fine. I
may have mistyped my example above.
>
>The spaces don't need to be escaped in either case; (|) need to be
>escaped for basic grep but not for egrep.
I escaped <space> for clarity.
--
gt kk5st@sbcglobal.net
If someone tells you---
"I have a sense of humor, but that's not funny."
---they don't.
Reply to: