I am trying to search for a string 0.49
(with dot) using the command
grep -r "0.49" *
But what happening is that I am also getting unwanted results which contains the string such as 0449
, 0949
etc,. The thing is linux considering dot(.) as any character and bringing out all the results. But I want to get the result only for "0.49".
grep
uses regexes; .
means "any character" in a regex. If you want a literal string, use grep -F
, fgrep
, or escape the .
to \.
.
Don't forget to wrap your string in double quotes. Or else you should use \\.
So, your command would need to be:
grep -r "0\.49" *
or
grep -r 0\\.49 *
or
grep -Fr 0.49 *