Friday, September 11, 2009

Linux Tip and Tricks continue...

Continuation with the day to day commands that I have compiled over the time.

Removing commented lines (starting with #) from a file
grep -v '^#' squid.conf >

To remove empty lines from a text file. I've been using sed with
sed '/^ *$/d' > squid.conf.nospace

Do the same thing with sed in one line
$ sed '/^#/d' squid.conf.default | sed /^$/d >

To remove all commented lines (starting with #) and blank lines from a file
sed -e '/^\(#\|$\)/ d' squid.conf.default >

Same thing using egrep
egrep -v '^(#|$)' squid.conf.default >

grep '^[^#]' squid.conf >

No comments:

Post a Comment