grep is a command line text search utility originally written for Unix. The name comes from the ed editor command, g/re/p (global / regular expression / print). The grep command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.
http://en.wikipedia.org/wiki/Grep
http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples
grep is not only one of the most useful commands, but also, mastery of grep opens the gates to mastery of other tools such as awk , sed and perl .
grep foo file returns all the lines that contain a string matching the expression "foo" in the file "file".
For now, we will just think of an expression as a string. So grep returns all matching lines that contain foo as a substring.
Another way of using grep is to have it accept data through STDIN. instead of having it search a file. For example,
ls |grep blah lists all files in the current directory whose names contain the string "blah"