How To Strip Comments From a File using GREP

Valic —  December 1, 2011 — 1 Comment

You can run this command to strip the comments (line that begins with a #) and remove blank lines from a file in Linux :

cat /path/to/file  | grep -v ^# | grep -v ^$

Example:

To remove comment lines from squid.conf you can run the following command:

cat /etc/squid/squid.conf | grep -v ^# | grep -v ^$ > squid_stripped.conf

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

One response to How To Strip Comments From a File using GREP

  1. Niece info, saving on bookmarks

Leave a Reply