Strip Comments from Config Files

Having comments in your config files is a good thing. However, many of the ‘stock’ config files come with loads of comment lines in them, and eventually you’ll want to get rid of them all without having to completely rewrite the file or manually remove them.  This command will do that:

grep -v “^#” configfile.conf | grep -v “^$” > new-configfile.conf

This will remove all lines starting with a #, along with any blank lines. For my setup, it took the default Squid config file from 4300+ lines down to a very manageable 56.