FGREP(1) COMMAND REFERENCE FGREP(1)
NAME
fgrep - search a file for a pattern
SYNOPSIS
fgrep [ -E ] [ -b ] [ -c ] [ -h ] [ -i ] [ -l ] [ -n ] [ -s
]
[ -v ] [ -x ] [ -y ] {[ -e ] string-list | -f file } [
filename ... ]
DESCRIPTION
Fgrep searches the input files for lines containing or
matching strings. If you don't specify files, standard
input is used. Normally, each line found is copied to the
standard output. Unless the -h option is given, the
filename is shown if there is more than one input file.
The string-list may be either specified on the command line,
or contained in a file. If you specify the string-list on
the command line, you must separate the strings by newlines,
and you may precede string-list with -e. The -e option is
useful for string-lists that begin with a '-'.
If the string-list is contained in a file, you must use the
-f filename option. If you don't specify the -e or -f
options, the string-list must come after all other options.
OPTIONS
-E Print matching lines in the format:
filename, line linenumber : matching line
-b Each line is preceded by the block number on which it
was found. This is sometimes useful in locating disk
block numbers by context.
-c Only a count of matching lines is printed.
-e string-list
Same as a simple string-list argument, but useful when
the string-list begins with a -.
-f file
The string list is taken from the file.
-h Suppress printing of filenames even if more than one
filename is given.
-i, -y
Ignore case of characters specified as lower case.
-l The names of files with matching lines are listed (once)
separated by newlines. If this option is given when
reading from standard input, fgrep simply exits with a
Printed 10/17/86 1
FGREP(1) COMMAND REFERENCE FGREP(1)
value of 1.
-n Each line is preceded by its relative line number in the
file.
-s Silent mode. No error messages are printed for
nonexistent files (does not apply to the string list
file).
-v All lines but those matching are printed.
-x (Exact) only lines matched in their entirety are
printed.
EXAMPLES
The following example searches all of the files in the
current directory for the sequence "date" and prints the
names of the files that contain this sequence.
fgrep -l date *
The following example copies all of the files in the current
directory that contain the sequence "date" to the standard
output.
cat `fgrep -l date *`
This example prints the lines in the file "example"
containing any of the words in the file "words".
fgrep -f words example
RETURN VALUE
[0] No errors occurred and at least one match was
found.
[USAGE] Incorrect command line syntax. Execution
terminated.
[1] No errors occurred but no matches were found.
[NP_ERR] An error occurred that was not a system
Printed 10/17/86 2
FGREP(1) COMMAND REFERENCE FGREP(1)
error. Execution terminated.
[P_ERR] A system error occurred. Execution
terminated. See intro(2) for more
information on system errors.
CAVEATS
If one of the input files is the same as the output, as in
the example ``egrep re * > out'', that input file is not
searched in order to prevent problems. No message is
printed in this case. If the old functionality is required,
pipe the output through cat(1).
The maximum number of strings for which fgrep can search
varies for different size strings.
The precedence of the output specification options is -c,
-E, and -l, which turn off the -n and -b options and the
printing of the file name and matching line.
Tests show that egrep is the fastest of the pattern
searching commands.
SEE ALSO
cat(1), egrep(1), grep(1), regcmp(1), sh(1sh).
Printed 10/17/86 3
%%index%%
na:72,71;
sy:143,440;
de:583,1152;
op:1735,1189;3068,416;
ex:3484,591;
rv:4075,395;4614,224;
ca:4838,827;
se:5665,184;
%%index%%000000000152