grep

A good source for information on grep is a book called, "The UNIX Programming Environment" by Kernighan & Pike. There's a nice short section on grep (4.1). I have it in my office, if any of my students would like to take a look at it.

The most common use for grep is for finding a particular word or short string in a file. The syntax is:

grep expression filename(s)

For example, you might want to find all the lines of code in your C files which refer to a particular variable.

grep 'count' *.c

How can you learn about grep?

1. type (on a Unix machine):
man grep

You can copy the manual page for grep to a file using '>' and then print that file. You should learn (or put on your cheat sheet) some of the main options for grep.

2. one of the other TAs has provided some links to documentation with many examples on a FAQ list

3. TRY IT!!

Here's some hints and highlights about grep: