[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. Invoking grep

grep comes with a rich set of options from POSIX.2 and GNU extensions.

`-c'
`--count'
Suppress normal output; instead print a count of matching lines for each input file. With the `-v', `--invert-match' option, count non-matching lines.

`-e pattern'
`--regexp=pattern'
Use pattern as the pattern; useful to protect patterns beginning with a `-'.

`-f file'
`--file=file'
Obtain patterns from file, one per line. The empty file contains zero patterns, and therefore matches nothing.

`-i'
`--ignore-case'
Ignore case distinctions in both the pattern and the input files.

`-l'
`--files-with-matches'
Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning of every file will stop on the first match.

`-n'
`--line-number'
Prefix each line of output with the line number within its input file.

`-o'
`--only-matching'
Print only the part of matching lines that actually matches pattern.

`-q'
`--quiet'
`--silent'
Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. Also see the `-s' or `--no-messages' option.

`-s'
`--no-messages'
Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, traditional grep did not conform to POSIX.2, because traditional grep lacked a `-q' option and its `-s' option behaved like GNU grep's `-q' option. Shell scripts intended to be portable to traditional grep should avoid both `-q' and `-s' and should redirect output to `/dev/null' instead.

`-v'
`--invert-match'
Invert the sense of matching, to select non-matching lines.

`-x'
`--line-regexp'
Select only those matches that exactly match the whole line.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by root on January, 23 2002 using texi2html