I have a file named example
$ cat example
kali.pdf
linux.pdf
ubuntu.pdf
example.pdf.
this.pdf
grep .pdf
and when I use grep
to get the line that has a space before .pdf
, I can't seem to get it.
grep *.pdf example
returns nothing, (I want to say, "grep, match zero or more spaces before .pdf
", but no result)
and if I use:
grep i*.pdf example
kali.pdf
linux.pdf
ubuntu.pdf
example.pdf.
this.pdf
grep .pdf
all lines return, because I'm saying "grep, match me i
one or zero times, ok."
and lastly:
grep " *.pdf" example
no result returns
For this sample, I want to see
grep .pdf
as output
What is wrong with my thought?
egrep
is (in terms of regex style, afaik) the same asgrep -E
, and I believe we are meant to use the latter -egrep
etc are supposedly deprecated in favour ofgrep
's flags – Zanna Aug 24 '17 at 13:37