How To Filter Blank Lines With GREP

[code]
# filter blank lines
grep -hv "^$" *
# filter blank lines and comments
grep -hv ‘^#’ * | grep -hv "^$"
# filter blank lines, and comments, then count number of lines
grep -hv ‘^#’ * | grep -hv "^$" | wc -l
[/code]
Note – using FreeBSD’s version of grep. The “-h” argument tells grep to NOT print file names at the beginning of the line. The “-v” says to SKIP matched lines.
Leave Your Comment
All fields marked with "*" are required.