Grep is used to search inside other files. The awful name comes from "Global Regular Expression Print", because although its simplistic use is much like Windows "FIND" command, it is actually much more powerful.
So while you could use it like:
grep "hello" *.c
it can also do much more complicated searches based on wild card patterns:
grep '^[Hh]ello *' *.c
which would look for "hello" or "Hello" at the beginning of a line followed by any number of spaces.
Unix people sometimes use grep in ordinary conversation, but it' s easy to look like a wannabe with this one, so don't try it while you are still wet behind the ears.
One of the questions people ask about grep is how to use it to search through files in sub-directories. You might think there's a simple, easy way to do that, but actually it can be pretty complicated. See How can I recursively grep through sub-directories? for some ways to do it.
In older Unix books, you'll sometimes find a hint to use "fgrep" instead of grep if you aren't using wildcards. That advice is no longer valid, so ignore it.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-03-09 Tony Lawrence