Strip comments and blank lines from file in Unix

This command displays configuration file stripping commented and blank lines on Unix-like operating system.

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

or

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

Your email is never shared. Required fields are marked with *.

*
*

Notify me of follow-up comments via e-mail. You can also subscribe without commenting.