grep

grep

This command searches a file or files for text strings. This will search for patterns in multiple files. Example: grep -wc turkey mytext 3 This returns the information that the whole word turkey is found 3 times in the file mytext. Options -A num number of lines after the matched pattern -B num number of lines before the matched pattern -c number of matches -C display two lines before and after each match -e pattern search for pattern -f file uses a pattern from a file -i ignore case -l lists files that contain matches -L lists files that have no matches -w lists whole words that are matched -x lists only whole lines that are matched