Thursday, December 18, 2008

Removing Comment Lines and Spaces in a File

How to remove comment lines and spaces on a configuration file in Linux?

To remove comment lines under Linux, issue the following command:

# sed -e '/^#/d' -e '/^$/d' < squid.conf > newsquid.conf

Then, go can backup the original squid.conf file by copying it to say squidconf.bak:

# cp squid.conf squidconf.bak

And finally copying the new squid file to replace the original file as:

# cp newsquid.conf squid.conf

No comments: