Sunday, 13 April 2014

Remove comments from a file on Linux with sed


You can quickly remove comments from a file on Linux using sed. For example if the comment starts with #.

$ sed '/^\#/d' filewithcomments.txt > filewithcomments.tmp
$ mv filewithcomments.tmp filewithcomments.txt
$ rm filewithcomments.tmp

No comments:

Post a Comment