I have this phantom block of code that is messing up my program, but I can simply NOT find where it is in my project. I know exactly (to the whitespace) what the code would be, but since it is code it has a lot of spaces, periods, brackets, ect. It would be a huge pain to type out a regular expression for the whole thing. Is there a way I could just search for an exact match to a string using grep -r
?
fgrep
does this (or grep -F
). Don't forget to quote the pattern to prevent the shell from interpreting it:
$ echo 'a' | grep '[abc]'
a
$ echo 'a' | fgrep '[abc]'
$ echo '[abc]' | fgrep '[abc]'
[abc]