The following returns a bunch of results including those containing “->emit”
grep -rnw '/var/www/react' -e ">emit"
But the following returns no results
grep -rnw '/var/www/react' -e "->emit"
Why?
Advertisement
Answer
You need to drop the -w option. It says to treat the expression as a whole word. A word must be bounded by non-word characters, i.e. it must only be surrounded by characters other than [a-zA-Z0-9_].
emit would match emit, _emit, or ->emit, but not remit.
I’m guessing that your ->emit is trying to match something like a->emit, but can’t because a is a word character.