'\" te .\" Copyright 1989 AT&T .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. .\" This notice shall appear on any product containing this material. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH FGREP 1 "Mar 24, 2006" .SH NAME fgrep \- search a file for a fixed-character string .SH SYNOPSIS .LP .nf \fB/usr/bin/fgrep\fR [\fB-bchilnsvx\fR] \fB-e\fR \fIpattern_list\fR [\fIfile...\fR] .fi .LP .nf \fB/usr/bin/fgrep\fR [\fB-bchilnsvx\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR] .fi .LP .nf \fB/usr/bin/fgrep\fR [\fB-bchilnsvx\fR] \fIpattern\fR [\fIfile...\fR] .fi .LP .nf \fB/usr/xpg4/bin/fgrep\fR [\fB-bchilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR] [\fIfile...\fR] .fi .LP .nf \fB/usr/xpg4/bin/fgrep\fR [\fB-bchilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR] .fi .LP .nf \fB/usr/xpg4/bin/fgrep\fR [\fB-bchilnqsvx\fR] \fIpattern\fR [\fIfile...\fR] .fi .SH DESCRIPTION .sp .LP The \fBfgrep\fR (fast \fBgrep\fR) utility searches files for a character string and prints all lines that contain that string. \fBfgrep\fR is different from \fBgrep\fR(1) and from \fBegrep\fR(1) because it searches for a string, instead of searching for a pattern that matches an expression. \fBfgrep\fR uses a fast and compact algorithm. .sp .LP The characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, |, \fB(\fR, \fB)\fR, and \fB\e\fR are interpreted literally by \fBfgrep\fR, that is, \fBfgrep\fR does not recognize full regular expressions as does \fBegrep\fR. These characters have special meaning to the shell. Therefore, to be safe, enclose the entire \fIstring\fR within single quotes (\fBa\'\fR). .sp .LP If no files are specified, \fBfgrep\fR assumes standard input. Normally, each line that is found is copied to the standard output. The file name is printed before each line that is found if there is more than one input file. .SH OPTIONS .sp .LP The following options are supported for both \fB/usr/bin/fgrep\fR and \fB/usr/xpg4/bin/fgrep\fR: .sp .ne 2 .na \fB\fB-b\fR\fR .ad .RS 19n Precedes each line by the block number on which the line was found. This can be useful in locating block numbers by context. The first block is 0. .RE .sp .ne 2 .na \fB\fB-c\fR\fR .ad .RS 19n Prints only a count of the lines that contain the pattern. .RE .sp .ne 2 .na \fB\fB-e\fR \fIpattern_list\fR\fR .ad .RS 19n Searches for a \fIstring\fR in \fIpattern-list\fR. This is useful when the \fIstring\fR begins with a \fB\(mi\fR\&. .RE .sp .ne 2 .na \fB\fB-f\fR \fIpattern-file\fR\fR .ad .RS 19n Takes the list of patterns from \fIpattern-file\fR. .RE .sp .ne 2 .na \fB\fB-h\fR\fR .ad .RS 19n Suppresses printing of files when searching multiple files. .RE .sp .ne 2 .na \fB\fB-i\fR\fR .ad .RS 19n Ignores upper/lower case distinction during comparisons. .RE .sp .ne 2 .na \fB\fB-l\fR\fR .ad .RS 19n Prints 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. .RE .sp .ne 2 .na \fB\fB-n\fR\fR .ad .RS 19n Precedes each line by its line number in the file. The first line is 1. .RE .sp .ne 2 .na \fB\fB-s\fR\fR .ad .RS 19n Works silently, that is, displays nothing except error messages. This is useful for checking the error status. .RE .sp .ne 2 .na \fB\fB-v\fR\fR .ad .RS 19n Prints all lines except those that contain the pattern. .RE .sp .ne 2 .na \fB\fB-x\fR\fR .ad .RS 19n Prints only lines that are matched entirely. .RE .SS "/usr/xpg4/bin/fgrep" .sp .LP The following options are supported for \fB/usr/xpg4/bin/fgrep\fR only: .sp .ne 2 .na \fB\fB-q\fR\fR .ad .RS 6n Quiet. Does not write anything to the standard output, regardless of matching lines. Exits with zero status if an input line is selected. .RE .SH OPERANDS .sp .LP The following operands are supported: .sp .ne 2 .na \fB\fIfile\fR\fR .ad .RS 8n Specifies a path name of a file to be searched for the patterns. If no \fIfile\fR operands are specified, the standard input will be used. .RE .SS "/usr/bin/fgrep" .sp .ne 2 .na \fB\fIpattern\fR\fR .ad .RS 11n Specifies a pattern to be used during the search for input. .RE .SS "/usr/xpg4/bin/fgrep" .sp .ne 2 .na \fB\fIpattern\fR\fR .ad .RS 11n Specifies one or more patterns to be used during the search for input. This operand is treated as if it were specified as \fB-e\fR \fIpattern_list\fR. .RE .SH USAGE .sp .LP See \fBlargefile\fR(5) for the description of the behavior of \fBfgrep\fR when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). .SH ENVIRONMENT VARIABLES .sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBfgrep\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .SH EXIT STATUS .sp .LP The following exit values are returned: .sp .ne 2 .na \fB\fB0\fR\fR .ad .RS 5n If any matches are found .RE .sp .ne 2 .na \fB\fB1\fR\fR .ad .RS 5n If no matches are found .RE .sp .ne 2 .na \fB\fB2\fR\fR .ad .RS 5n For syntax errors or inaccessible files, even if matches were found. .RE .SS "/usr/xpg4/bin/fgrep" .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ CSI Enabled .TE .SH SEE ALSO .sp .LP \fBed\fR(1), \fBegrep\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBXPG4\fR(5) .SH NOTES .sp .LP Ideally, there should be only one \fBgrep\fR command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs. .sp .LP Lines are limited only by the size of the available virtual memory. .SS "/usr/xpg4/bin/fgrep" .sp .LP The \fB/usr/xpg4/bin/fgrep\fR utility is identical to \fB/usr/xpg4/bin/grep\fR \fB-F\fR (see \fBgrep\fR(1)). Portable applications should use \fB/usr/xpg4/bin/grep\fR \fB-F\fR.