grep—searches a file for a pattern
grep [ –bchilnsvw ] limited–regular–expression [ filename ... ]
grep searches files for a pattern and prints all lines that contain that pattern. Uses regular expression metacharacters to match the patterns. egrep has an extended set of metacharacters.
Example A.32.
1 grep Tom file1 file2 file3
2 grep -in '^tom savage' *
EXPLANATION
Grep displays all lines in file1, file2, and file3 that contain the pattern Tom. Grep displays all lines with line numbers from the files in the current working directory that contain tom savage if tom savage is at the beginning of the line, ignoring case.
|