dotancohen dotancohen - 4 months ago 6x
Linux Question

Grep not as a regular expression

I need to search for a PHP variable

. However, Grep thinks that I am trying to run a regex and is complaining:

$ grep -ir "Something Here" * | grep $someVar
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
$ grep -ir "Something Here" * | grep "$someVar"
<<Here it returns all rows with "someVar", not only those with "$someVar">>

I don't see an option for telling grep not to interpret the string as a regex, but to include the
as just another string character.


Escape the $ by putting a \ in front of it.