grep.1 (2010 09)

g
grep(1) grep(1)
NAME
grep, egrep, fgrep - search a file for a pattern
SYNOPSIS
Plain call with pattern
grep [-E -F][
-c-l-q][-bhinsvwx] pattern [ file ... ]
Call with (multiple) e pattern
grep [-E -F][-c
-l-q][-bhinsvwx] -e pattern ... [-e pattern ] ... [ file ... ]
Call with ffile
grep [-E -F][-c
-l-q][-bhinsvwx][-f pattern_ file ][file ... ]
Obsolescent:
egrep [-cefilnsv][expression ][file ... ]
fgrep [-cefilnsvx][strings ][file ... ]
DESCRIPTION
The
grep command searches the input text files (standard input default) for lines matching a pattern.
Normally, each line found is copied to the standard output.
grep supports the Basic Regular Expression
syntax (see regexp (5)). The -E option (egrep) supports Extended Regular Expression (ERE) syntax (see
regexp (5)). The -F option (fgrep) searches for fixed strings using the fast Boyer-Moore string searching
algorithm. The -E and -F options treat newlines embedded in the pattern as alternation characters. A
null expression or string matches every line.
The forms
egrep and fgrep are maintained for backward compatibility. The use of the
-E and -F
options is recommended for portability.
Options
-E Extended regular expressions. Each pattern specified is a sequence of one or
more EREs. The EREs can be separated by newline characters or given in
separate -e expression options. A pattern matches an input line if any ERE
in the sequence matches the contents of the input line without its trailing new-
line character. The same functionality is obtained by using
egrep.
-F Fixed strings. Each pattern specified is a sequence of one or more strings.
Strings can be separated by newline characters or given in separate -e expres-
sion options. A pattern matches an input line if the line contains any of the
strings in the sequence. The same functionality is obtained by using
fgrep.
-b Each line is preceded by the block number on which it was found. This is use-
ful in locating disk block numbers by context. Block numbers are calculated
by dividing by 512 the number of bytes that have been read from the file and
rounding down the result.
-c Only a count of matching lines is printed.
-e expression Same as a simple expression argument, but useful when the expression begins
with a hyphen (-). Multiple -e options can be used to specify multiple pat-
terns; an input line is selected if it matches any of the specified patterns.
-f pattern_ file The regular expression (grep and grep -E)orstrings list (grep -F)is
taken from the pattern_ file.
-h Suppress printing of filenames when searching multiple files.
-i Ignore uppercase/lowercase distinctions during comparisons.
-l Only the names of files with matching lines are listed (once), separated by
newlines. If standard input is searched, a path name of (standard
input) will be written, in the POSIX locale. In other locales, (standard
input) may be replaced by something more appropriate in those locales.
-n Each line is preceded by its relative line number in the file starting at 1. The
line number is reset for each file searched. This option is ignored if -c, -b, -
l,or-q is specified.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (4 pages)