By Corey Stokes 9/14/10
What is grep? Global Regular Expression Print grep is a command line search utility in Unix Try: Search for a word in a.cpp file - grep ‘cat’ cat.cpp
What can it do? Copy next input line into pattern space Apply regular expression to patter space Copies matches to output CopyApplyOutput
grep Family egrep Allows for more complex patterns fgrep Good for searching text characters Uses sequence operations e.g.: (),“”, ` grep Uses all regular expressions Only one that allows saving
Commands CommandDescription -bPrecedes each line by the file block # -cPrints only a count of the number of lines matching the pattern -iIgnores upper/lower case matching -nShows the line numbers -sSilent Mode(no output) -vInverse Output (lines that don’t match) -xPrints only lines that entirely match -f fileList of strings to be matched are in a file
Searching grep can search for files with the same name in a directory Find command locates the path of a file
Limitations Cannot modify a link Cannot print part of a line Cannot read only part of a file Only hold one buffer based on the current line
Have Fun! Try figuring out how to make search results more specific There is a way!