

Command line made easy: five simple recipes for grep - j_baker
http://arstechnica.com/open-source/news/2009/05/command-line-made-easy-five-simple-recipes-for-grep.ars

======
pkulak
grep -c "^<segph\\(ault\|one\\)>" channel.log

Anyone know why all the syntax is escaped there?

~~~
RiderOfGiraffes
Yes. If not escaped grep will consider the syntax as literals and search for
them. Being escaped makes grep treat them as syntactic elements of the regular
expression, not characters to match.

For example, "te(s|x)t" will match neither "test" nor "text", but will match
anything that has "te(s|x)t" in it. On the other hand, "te\\(s\|x\\)t" will
match any line with "test" or "text" in it.

