grep ``string'' filename
Suppose you wished to find the word ``boulevard'' in the file ``sharky'', you would type the following command:
malama% grep boulevard sharky
Disappearing behind the boulevard
malama%
You may use grep to search for a string in a whole group of files. To look in more than one file use the wild card character ``*'' (to find out about wild cards see the section in this file on Commands). The format is:
grep string *
grep will search through all the files in your current directory looking for each occurrence of the specified string.
Note that the format for grep is the reverse of its counterpart in VMS, the command search (the format for search is ``search filename `string' '').
To make more complicated searches, such as matching more than one expression, you will probably have to use the other commands in the grep family, egrep and fgrep. For more details on their usage, check the on-line man pages.
In case you are wondering where the name ``grep'' comes from, it is short for ``get regular expression and print''. There are two other versions of ``grep'', one faster but more restrictive in allowed expressions fgrep, one more extensive egrep.