Grep allows you to use regular expressions to match patterns within the file using the
-E flag, or you can use the
egrep command which is equivalent to
grep -E 'A1|B3|C2' filename
egrep 'A1|B3|C2' filename
The vertical bar,
|, is the OR operator meaning match string A1 or B3 or C2.
Regular expression syntax varies from tool to tool, but generally the syntax is the same. Here is a regex test harness for Ruby that I use frequently to test and build regular expressions: http://rubular.com/r/mJyIMO5hJN
However, any introduction to regular expressions should be prefaced with a warning that they are limited in their capabilities, and the adage is:
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.