Delete all lines beginning with a # from a file

bash, sed

Solution

This can be done with a sed one-liner:

sed '/^#/d'

This says, "find all lines that start with # and delete them, leaving everything else."

Problem

All of the lines with comments in a file begin with `#`. How can I delete all of the lines (and only those lines) which begin with `#`? Other lines containing `#`, but not at the beginning of the line should be ignored.

Original source

Related problems