Strip comments and blank lines from file in Unix

Command shown below displays configuration file and strips commented and blank lines on Unix-like operating system.

grep -E -v '^\s*#|^\s*$|^\s*;' file

or

egrep -v '^\s*#|^\s*$|^\s*;' file

Leave a Reply

You may use simple HTML to add links or lists to your comment. Also use <pre><code class="language-*">...</code></pre> to mark up code snippets. We support language-js, language-markup and language-css for comments.
(Optional)