grep-searches a file for a pattern

 <  Day Day Up  >  

grep ”searches a file for a pattern

 grep [ bchilnsvw ] limitedregularexpression [ 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

  1. Grep displays all lines in file1 , file2 , and file3 that contain the pattern Tom .

  2. 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.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net