How can I find a string which includes quotation marks with grep? I tried a backslash to escape but this doesn't work.
For example search for the string "localStorage['api']"
.
I tried:
grep -r "localStorage['api']" /path
grep -r "localStorage[\'api\']" /path
Your escaping is OK. The problem lies in the
[]
, thatgrep
understands as regular expressions. Thus, you need to somehow tell it to treat the string as literal. For this we have-F
:Test
From
man grep
: