What is difference between
grep -isn "String\.format" -R .
and
grep -isn String\.format -R .
When I use the latter, the results include String format and String.format, but if I use the former, the results only include String.format. This result is same as using
grep -isn 'String\.format' -R .
Can anyone give an explanation?
Without quotation marks, the shell interprets
\.as a.before passing the string togrep. Sogrepnow has a regular expression wildcard and can thus find any character, including a space.When you included quotation marks, the shell passed the full
\.togrep. Nowgrepknows that it must search for a period, and not a wildcard.