Remove comments Remove comment lines using sed and a regular expression on a file. #.*$ comment in Perl for example $ sed -e 's/#.*$//' somescript.pl References Stack Overflow