Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
fgrep(1) OSS Shell and Utilities Reference Manual
NAME
fgrep - Searches a file for a fixed-string pattern
SYNOPSIS
fgrep
[-c | -l]
[-bhinqsvx]
{ pattern ... | -e pattern ... | -f pattern_file ... }
[file ... ]
FLAGS
While most flags can be combined, some combinations result in one flag overriding another. For
example, if you specify both the -n and -l flags, the output includes only filenames (as specified by
the -l flag) and thus does not include line numbers (as specified by the -n flag).
-b Precedes each line by the block number of the block in which it was found. Use this flag
to help find disk block numbers by context.
-c Displays only a count of matching lines.
-e pattern ...
Specifies a pattern. This flag works the same as a simple pattern but is useful when the
pattern begins with a - (dash).
-f pattern_file ...
Specifies a file that contains patterns. Each pattern terminates with a newwline charac-
ter.
-h Suppresses reporting of filenames when multiple files are processed.
-i Ignores the case of letters in locating pattern; that is, uppercase and lowercase letters in
the input are considered to be identical.
-l Lists the name of each file that has lines matching pattern. Each filename is listed only
once; filenames are separated by newline characters.
-n Precedes each line with its relative line number in the file.
-q Suppresses all output except error messages. This flag is useful for easily determining
whether a pattern or string exists in a group of files. When searching several files, it pro-
vides a performance improvement, because it can quit as soon as it finds the first match,
and it requires less care by the user in choosing the set of files to supply as arguments,
because it exits with a 0 (zero) exit status if it detects a match, even if the fgrep com-
mand detected an access or read error on earlier file arguments.
-s Suppresses error messages about inaccessible files.
-v Displays all lines except those that match the specified pattern. This flag is useful for
filtering unwanted lines out of a file.
-x Displays lines that match the pattern exactly with no additional characters.
DESCRIPTION
The fgrep command searches the specified files (the standard input file by default) for lines con-
taining characters that match the specified pattern and then writes the matching lines to the stan-
dard output file.
The fgrep command is an obsolescent version of the command grep -F, which searches for pat-
terns that are fixed strings.
3−128 Hewlett-Packard Company 527188-003