This is a really simple question, but even after reading about wildcards/regex, I can't seem to grasp entirely what the differences between these commands are:
grep . test.txt
this one will look for lines containing any character in test.txt
grep \. test.txt
this one also apparently does the exact same thing, even though I assumed it shouldn't, since it would be escaped and return only those lines containing an actual '.'
grep ? test.txt
since ? is a special character, I guess it would be interpreted as a wildcard, but since grep doesn't deal with wildcards, it's not going to output anything; however
grep \? test.txt
does find the lines which contain an '?' in them, but also those that contain an '\?' in them. Why is this?
grep \., the shell sees the backslash as an escape character, but a dot doesn't need escaping, so it's converted to.. So both commands look the same togrep. Trygrep '\.'. – Mikel May 24 '15 at 19:17?there are several things to point out. First,grepgets to see the unescaped?because you don't have one-character filenames in the current directory. Second,\?is expanded by the shell to?. And third,?has no special meaning forgrep. It starts being special foregrep, or forgrep -E, orgrep -P. Plaingrepexpects basic regexps (BRE), and?is nor special in the BRE dialect. – lcd047 May 24 '15 at 19:29