1 2 3 4 5 6 7 8 9

Operators

*After an expression, this will match n duplications
(
n can be zero, i.e. the NULL string) xyexpression x followed by expression y

\(...\)

delimits a subexpression

\nwhere n in range 0-9, \n matches the n-th
subexpression found in this line

UNIX grep command

grep 'regex' ListofFiles

this command scans all the characters in the files specified,
and prints out every line that contains at least one
match with the regular expression 'regex' given.

e.g.
cd /usr/include
grep '.printf' *.h

scans all the .h files and prints out lines containing .printf Note you need the single quotes here, since the regular
expression contains the special symbol [.]

Remember that UNIX is a line-oriented operating system--
really all the utilities work on text files, on a line by
line basis.

4 February, 1998

7

Copyright University of Alberta