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 > squid.conf.new
To remove empty lines from a text file. I've been using sed with
sed '/^ *$/d' squid.conf.new > squid.conf.nospace
Do the same thing with sed in one line
$ sed '/^#/d' squid.conf.default | sed /^$/d > squid.conf.new
To remove all commented lines (starting with #) and blank lines from a file
sed -e '/^\(#\|$\)/ d' squid.conf.default > squid.conf.new
Same thing using egrep
egrep -v '^(#|$)' squid.conf.default > squid.conf.new
OR
grep '^[^#]' squid.conf > squid.conf.new
No comments:
Post a Comment