Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fgrep(1) — SunOS 5.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed(1)

egrep(1)

grep(1)

sed(1)

sh(1)

environ(5)

fgrep(1)

NAME

fgrep − search a file for a character string

SYNOPSIS

fgrep [ −bchilnsvx ] [ −e special string ] [ −f filename ] [ strings ] [ filename ... ]

AVAILABILITY

SUNWcsu

DESCRIPTION

fgrep (fast grep) searches files for a character string and prints all lines that contain that string.  fgrep is different from grep(1) and egrep(1) because it searches for a string, instead of searching for a pattern that matches an expression.  It uses a fast and compact algorithm. 

The characters $, ∗, [, ^, │, (, ), and \ are interpreted literally by fgrep, that is, fgrep does not recognize full regular expressions as does egrep.  Since these characters have special meaning to the shell, it is safest to enclose the entire string in single quotes ′...′. 

If no files are specified, fgrep assumes standard input.  Normally, each line found is copied to the standard output.  The file name is printed before each line found if there is more than one input file. 

OPTIONS

−b Precede each line by the block number on which it was found.  This can be useful in locating block numbers by context (first block is 0). 

−c Print only a count of the lines that contain the pattern. 

−h Suppress printing of filenames when searching multiple files. 

−i Ignore upper/lower case distinction during comparisons. 

−l Print the names of files with matching lines once, separated by new-lines.  Does not repeat the names of files when the pattern is found more than once. 

−n Precede each line by its line number in the file (first line is 1). 

−s Work silently, that is, display nothing except error messages.  This is useful for checking the error status. 

−v Print all lines except those that contain the pattern. 

−x Print only lines matched entirely. 

−e special_string
Search for a special string (string begins with a −). 

−f filename Take the list of strings from filename.

ENVIRONMENT

If any of the LC_∗ variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of fgrep for each corresponding locale category is determined by the value of the LANG environment variable.  If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables.  If none of the above variables is set in the environment, the "C"  (U.S. style) locale determines how fgrep behaves. 

LC_CTYPE
Determines how fgrep handles characters. When LC_CTYPE is set to a valid value, fgrep can display and handle text and filenames containing valid characters for that locale.  fgrep can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide.  fgrep can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid. 

LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses.  In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S./English).

SEE ALSO

ed(1), egrep(1), grep(1), sed(1), sh(1), environ(5)

DIAGNOSTICS

Exit status is 0 if any matches are found, 1 if none, 2 for syntax errors or inaccessible files (even if matches were found). 

NOTES

Ideally there should be only one grep command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs.  Lines are limited to BUFSIZ characters; longer lines are truncated.  BUFSIZ is defined in <stdio.h>f1. 

SunOS 5.2  —  Last change: 14 Sep 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026