[Top] [Prev] [Next]

grep

grep - search file(s) for a pattern

Synopsis

grep [-l] [-n] [-e pattern] [-v] pattern [file... ]

Description

The grep command searches the input files (standard input, by default) for lines that match the pattern, a regular expression as defined in regex. Lines matching the pattern ('matching' lines) are printed to the standard output.

The minus (' - ') sign can be used on the command line to explicitly name standard input as an input source. The following command will search file1, then standard input, then file2.

	grep pattern file1 - file2

Options
-l

Print (once) the names of files with any matching lines; the matched lines are not printed.

-n

Prefix each line of output with its line number within its file.

-v

Reverse: print lines that do not match the pattern.

-e pattern

Use the following field as the pattern for selecting lines. Handy when searching for patterns that might be interpreted as options. The following command searches for instances of -n in file.

    grep -e -n file

See Also

regex



[Top] [Prev] [Next]

infernosupport@lucent.com
Copyright © 1996,Lucent Technologies, Inc. All rights reserved.