Grep acts differently depending on what kind of quotes I surround the regex with. I can\'t seem to get a clear understanding of why this is. Here is an example of the problem:>
In order:
grep -e show( test.txt
does not work, because the shell interprets the (
as special, a parenthesis, not just a character, and can't find the closing )
.
These both work:
grep -e 'show(' test.txt
grep -e "show(" test.txt
because the shell treats the quoted text as just text, and passes it to grep.
These do not work:
grep -e 'show\(' test.txt
grep -e "show\(" test.txt
because the shell passes show\(
to grep, grep sees \(
as special, a parenthesis, not just a character, and can't find the closing \)
.