1

Can some explain the meaning of grep . filename, what does the . (dot) means here.?

Actually it removed all the empty lines in my file.
I just want to know how it's working.

1 Answer 1

4

in grep a dot is meant to be a regex so it stands for any character. If you want to grep occurrences of '.' you can use

grep '\.' filename

(or use fgrep which equals grep -F)

fgrep . filename

Note: If there is an empty line containing a space, it will be shown in the output of:

grep . filename

Why it does not match empty lines? Because there is no character in empty line between ^ and $ (start and end of line). Empty lines-only grep is:

grep '^$' filename

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .