grep Regular expressions Regular expressions


The search pattern can also be a regular expression. Running:

grep '^[A-Z]' someFile.txt

When someFile.txt contains:

fred 14 m foo
sam 68 m bar
christina 83 f baz
bob 22 m qux
Sam 41 m quux

Will produce the output:

Sam 41 m quux

since this is the only line in someFile.txt starting with an upper case letter.