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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
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
fgrep which equals
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
$ (start and end of line). Empty lines-only grep is:
grep '^$' filename