'\" te .\" Copyright 1989 AT&T .\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved .\" 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. .TH fgrep 1 "2010 年 3 月 23 日" "SunOS 5.11" "用户命令" .SH 名称 fgrep \- 搜索文件中的固定字符串 .SH 用法概要 .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 描述 .sp .LP \fBfgrep\fR(固定的 \fBgrep\fR)实用程序将搜索文件以查找字符串,并列显包含该字符串的所有行。\fBfgrep\fR 与 \fBgrep\fR(1) 和 \fBegrep\fR(1) 不同,因为其搜索字符串而不是与表达式匹配的模式。 .sp .LP \fBfgrep\fR 将逐字地对 \fB$\fR、\fB*\fR、\fB[\fR、\fB^\fR、|、\fB(\fR、\fB)\fR 和 \fB\\fR 等字符进行解释,也即,\fBfgrep\fR 不能像 \fBegrep\fR 那样识别完整的正则表达式。这些字符在 shell 中具有特殊含义。因此,为了安全起见,请将整个\fI字符串\fR括在单引号 (\fB´\fR) 中。 .sp .LP 如果未指定任何文件,\fBfgrep\fR 将采用标准输入。通常情况下,找到的每一行都将复制到标准输出中。如果有多个输入文件,将先列显文件名,再查找每一行。 .SH 选项 .sp .LP \fB/usr/bin/fgrep\fR 和 \fB/usr/xpg4/bin/fgrep\fR 均支持以下选项: .sp .ne 2 .mk .na \fB\fB-b\fR\fR .ad .RS 19n .rt 每一行前面均带有该行所在的块编号。这在通过上下文查找块编号时十分有用。第一个块为 0。 .RE .sp .ne 2 .mk .na \fB\fB-c\fR\fR .ad .RS 19n .rt 仅列显包含该模式的行计数。 .RE .sp .ne 2 .mk .na \fB\fB-e\fR \fIpattern_list\fR\fR .ad .RS 19n .rt 在 \fIpattern-list\fR 中搜索\fI字符串\fR。当\fI字符串\fR以 \fB-\fR 开头时十分有用。 .RE .sp .ne 2 .mk .na \fB\fB-f\fR \fIpattern-file\fR\fR .ad .RS 19n .rt 使用 \fIpattern-file\fR 中的模式列表。 .RE .sp .ne 2 .mk .na \fB\fB-h\fR\fR .ad .RS 19n .rt 搜索多个文件时,禁止列显文件。 .RE .sp .ne 2 .mk .na \fB\fB-i\fR\fR .ad .RS 19n .rt 在比较期间忽略大/小写区别。 .RE .sp .ne 2 .mk .na \fB\fB-l\fR\fR .ad .RS 19n .rt 列显一次具有匹配行的文件名(以换行符分隔)。多次找到模式时不重复文件的名称。 .RE .sp .ne 2 .mk .na \fB\fB-n\fR\fR .ad .RS 19n .rt 每一行前面均带有其在文件中的行编号。第一行为 1。 .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fR .ad .RS 19n .rt 执行时无提示,即,除错误消息外不显示任何内容。这对于检查错误状态很有用。 .RE .sp .ne 2 .mk .na \fB\fB-v\fR\fR .ad .RS 19n .rt 列显包含模式的行以外的所有行。 .RE .sp .ne 2 .mk .na \fB\fB-x\fR\fR .ad .RS 19n .rt 仅列显完全匹配的行。 .RE .SS "/usr/xpg4/bin/fgrep" .sp .LP \fB/usr/xpg4/bin/fgrep\fR 仅支持以下选项: .sp .ne 2 .mk .na \fB\fB-q\fR\fR .ad .RS 6n .rt 静默。不向标准输出写入任何内容(不考虑匹配行)。如果选择输入行,则以零状态退出。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .RS 8n .rt 指定要从中搜索模式的文件的路径名。如果未指定 \fIfile\fR 操作数,将使用标准输入。 .RE .SS "/usr/bin/fgrep" .sp .ne 2 .mk .na \fB\fIpattern\fR\fR .ad .RS 11n .rt 指定要在搜索输入内容期间使用的模式。 .RE .SS "/usr/xpg4/bin/fgrep" .sp .ne 2 .mk .na \fB\fIpattern\fR\fR .ad .RS 11n .rt 指定要在搜索输入内容期间使用的一个或多个模式。此操作数被视为如同指定为 \fB-e\fR \fIpattern_list\fR。 .RE .SH 用法 .sp .LP 有关 \fBfgrep\fR 遇到大于或等于 2 GB(2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 环境变量 .sp .LP 有关影响 \fBfgrep\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLC_COLLATE\fR、\fB LC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 5n .rt 如果找到任何匹配项 .RE .sp .ne 2 .mk .na \fB\fB1\fR\fR .ad .RS 5n .rt 如果找不到任何匹配项 .RE .sp .ne 2 .mk .na \fB\fB2\fR\fR .ad .RS 5n .rt 对于语法错误或不能访问的文件(即使找到匹配项)。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .SS "/usr/bin/fgrep" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os .TE .SS "/usr/xpg4/bin/fgrep" .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/xopen/xcu4 _ CSIEnabled(已启用) .TE .SH 另请参见 .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 附注 .sp .LP 理想情况下,应该只有一个 \fBgrep\fR 命令,但目前没有一种算法可以足够广泛地涵盖各种空间和时间权衡的情况。 .sp .LP 行仅受可用虚拟内存大小的限制。 .SS "/usr/xpg4/bin/fgrep" .sp .LP \fB/usr/xpg4/bin/fgrep\fR 实用程序与 \fB/usr/xpg4/bin/grep\fR \fB-F\fR 相同(请参见 \fBgrep\fR(1))。可移植应用程序应当使用 \fB/usr/xpg4/bin/grep\fR \fB-F\fR。