how to filter special characters and blank lines in unix

204 Views Asked by At

I want to display lines containing blank lines and special characters (?#!%#). i used grep command for special characters but its not working for blank line.

grep -n '[]?#!*%[]' file

if someone can please try this one? Thank you

1

There are 1 best solutions below

0
On

You can specify multiple patterns with -e options, so in addition to the present pattern you can give another one for lines containing nothing but blanks:

grep -n -e '[]?#!*%[]' -e '^ *$' file