Mukul Singh wrote:
David C. Rankin wrote:
Rodney Baker wrote:
See? I always 'sed' it was a powerful tool, if only one knew how to use it...;-)
Seriously, thanks Dave for another Really Useful Post. This one definitely gets filed away in my toolbox. :-)
Glad you find it useful. Now all I have to do is wait on the Linux God for my next epiphany.... Like you sed once I figure out sed, they say it is quite useful ;-)
Or you can do :
cat <filename> | egrep -v "^[[:space:]]*$|^#"
I like it, but from what I can tell it doesn't handle the '^:space:#' or
'^:space:;' or '^;' situations. I used to rely on egrep alot until working to
eliminate '|' pipes in my expressions. Then, it becomes apparent that the
flexibility in sed with the ability to author multiple expressions for the same
input without piping wins hands down. Using your expression, I would have first
eliminated the pipe and cat all together rewriting as:
egrep -v "^[[:space:]]*$|^#" <filename>
No need for two commands with a pipe in the middle where one will do. However,
you did help me catch a typo in what I had posted. The expression should have been:
sed -e '/^\s*$/d' -e '/^\s*[#;]/d'