Match empty lines and commented lines using grep

An example of a configuration file with many commented lines is /etc/sysctl.conf. If you wanted to display the contents of the file without the commented lines, the following command may be issued.

grep -v '^#' /etc/sysctl.conf
However the resulting contents will be displayed with the remaining blank lines.

To get around this one of a couple of commands may be issued.

grep -v '^#' /etc/sysctl.conf | awk 'NF'
grep -v '^#\|^$' /etc/sysctl.conf

Source(s)
http://stackoverflow.com/questions/18566169/match-empty-lines-in-a-file-grep
http://stackoverflow.com/questions/3432555/remove-blank-lines-with-grep