Remove commented lines from a file with sed

This is my very first post, welcome to the techteam.us blog.

I specifically wanted to remove commented lines from a configuration file so I could see the wood for the trees. This is a useful little linux one liner will remove commented lines from a file with sed, in this case lines beginning with the ‘;’ character. Obviously the ; can be changed to any character you fancy.

sed -i ‘/^[;]/ d’ hamster.txt

As always backup the original file before trying this out.