Grep tips

Grep is a handy Unix/Linux command for searching for lines in files that containg a particular string. Example:

grep "cat" foo

prints all lines of file "foo" that contains "cat".

Do a web search for "grep" to get a full manual.

However, one subtlety is not clear to me from the man page or online manuals.

Matching either of two strings

To print lines that contain either "red" or "blue", type

grep "red\|blue" foo

Notice the backslash ("\") before the infix ("|") symbol. Without this, it does not work.