How do I write a simple search pattern using a regular expression?
In a regular expression, everything is a generalized pattern. If I type the word “serendipitous” into my editor, I’ve created one instance of the word “serendipitous.” If, however, I indicate to my tool (or compiler, or editor, or what have you) that I’m now typing a regular expression, I am in effect creating a template that matches all instances of the characters “s,” “e,” “r,” “e,” “n,” “d,” “i,” “p,” “i,” “t,” “o,” “u,” and “s” all in a row. The standard way to find “serendipitous” (the word) in a file is to use “serendipitous” (the regular expression) with a tool like egrep (or extended grep): $ egrep “serendipitous” foobar >hits This line, as you might guess, asks egrep to find instances of the pattern “serendipitous” in the file “foobar” and write the results to a file called “hits”.