⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grep.1

📁 linux平台中
💻 1
📖 第 1 页 / 共 2 页
字号:
.\" grep man page.if !\n(.g \{\.	if !\w|\*(lq| \{\.		ds lq ``.		if \w'\(lq' .ds lq "\(lq.	\}.	if !\w|\*(rq| \{\.		ds rq ''.		if \w'\(rq' .ds rq "\(rq.	\}.\}.de Id.ds Dt \\$4...Id $Id: grep.1,v 1.23 2002/01/22 13:20:04 bero Exp $.TH GREP 1 \*(Dt "GNU Project".SH NAMEgrep, egrep, fgrep \- print lines matching a pattern.SH SYNOPSIS.B grep.RI [ options ].I PATTERN.RI [ FILE .\|.\|.].br.B grep.RI [ options ].RB [ \-e.I PATTERN|.B \-f.IR FILE ].RI [ FILE .\|.\|.].SH DESCRIPTION.PP.B Grepsearches the named input.IR FILE s(or standard input if no files are named, orthe file name.B \-is given)for lines containing a match to the given.IR PATTERN .By default,.B grepprints the matching lines..PPIn addition, two variant programs.B egrepand.B fgrepare available..B Egrepis the same as.BR "grep\ \-E" ..B Fgrepis the same as.BR "grep\ \-F" ..SH OPTIONS.TP.BI \-A " NUM" "\fR,\fP \-\^\-after-context=" NUMPrint.I NUMlines of trailing context after matching lines.Places a line containing.B \-\^\-between contiguous groups of matches..TP.BR \-a ", " \-\^\-textProcess a binary file as if it were text; this is equivalent to the.B \-\^\-binary-files=textoption..TP.BI \-B " NUM" "\fR,\fP \-\^\-before-context=" NUMPrint.I NUMlines of leading context before matching lines.Places a line containing.B \-\^\-between contiguous groups of matches..TP.BI \-C " NUM" "\fR,\fP \-\^\-context=" NUMPrint.I NUMlines of output context.Places a line containing.B \-\^\-between contiguous groups of matches..TP.BR \-b ", " \-\^\-byte-offsetPrint the byte offset within the input file beforeeach line of output..TP.BI \-\^\-binary-files= TYPEIf the first few bytes of a file indicate that the file contains binarydata, assume that the file is of type.IR TYPE .By default,.I TYPEis.BR binary ,and.B grepnormally outputs eithera one-line message saying that a binary file matches, or no message ifthere is no match.If.I TYPEis.BR without-match ,.B grepassumes that a binary file does not match; this is equivalent to the.B \-Ioption.If.I TYPEis.BR text ,.B grepprocesses a binary file as if it were text; this is equivalent to the.B \-aoption..I Warning:.B "grep \-\^\-binary-files=text"might output binary garbage,which can have nasty side effects if the output is a terminal and if theterminal driver interprets some of it as commands..TP.BI \-\^\-colour[=\fIWHEN\fR] ", " \-\^\-color[=\fIWHEN\fR]Surround the matching string with the marker find in.B GREP_COLORenvironment variable. WHEN may be `never', `always', or `auto'.TP.BR \-c ", " \-\^\-countSuppress normal output; instead print a count ofmatching lines for each input file.With the.BR \-v ", " \-\^\-invert-matchoption (see below), count non-matching lines..TP.BI \-D " ACTION" "\fR,\fP \-\^\-devices=" ACTIONIf an input file is a device, FIFO or socket, use.I ACTIONto process it.  By default,.I ACTIONis.BR read ,which means that devices are read just as if they were ordinary files.If.I ACTIONis.BR skip ,devices are silently skipped..TP.BI \-d " ACTION" "\fR,\fP \-\^\-directories=" ACTIONIf an input file is a directory, use.I ACTIONto process it.  By default,.I ACTIONis.BR read ,which means that directories are read just as if they were ordinary files.If.I ACTIONis.BR skip ,directories are silently skipped.If.I ACTIONis.BR recurse ,.B grepreads all files under each directory, recursively;this is equivalent to the.B \-roption..TP.BR \-E ", " \-\^\-extended-regexpInterpret.I PATTERNas an extended regular expression (see below)..TP.BI \-e " PATTERN" "\fR,\fP \-\^\-regexp=" PATTERNUse.I PATTERNas the pattern; useful to protect patterns beginning with.BR \- ..TP.BR \-F ", " \-\^\-fixed-stringsInterpret.I PATTERNas a list of fixed strings, separated by newlines,any of which is to be matched..BR \-P ", " \-\^\-perl-regexpInterpret.I PATTERNas a Perl regular expression..TP.BI \-f " FILE" "\fR,\fP \-\^\-file=" FILEObtain patterns from.IR FILE ,one per line.The empty file contains zero patterns, and therefore matches nothing..TP.BR \-G ", " \-\^\-basic-regexpInterpret.I PATTERNas a basic regular expression (see below).  This is the default..TP.BR \-H ", " \-\^\-with-filenamePrint the filename for each match..TP.BR \-h ", " \-\^\-no-filenameSuppress the prefixing of filenames on outputwhen multiple files are searched..TP.B \-\^\-helpOutput a brief help message..TP.BR \-IProcess a binary file as if it did not contain matching data; this isequivalent to the.B \-\^\-binary-files=without-matchoption..TP.BR \-i ", " \-\^\-ignore-caseIgnore case distinctions in both the.I PATTERNand the input files..TP.BR \-L ", " \-\^\-files-without-matchSuppress normal output; instead print the nameof each input file from which no output wouldnormally have been printed.  The scanning will stopon the first match..TP.BR \-l ", " \-\^\-files-with-matchesSuppress normal output; instead printthe name of each input file from which outputwould normally have been printed.  The scanning willstop on the first match..TP.BI \-m " NUM" "\fR,\fP \-\^\-max-count=" NUMStop reading a file after.I NUMmatching lines.  If the input is standard input from a regular file,and.I NUMmatching lines are output,.B grepensures that the standard input is positioned to just after the lastmatching line before exiting, regardless of the presence of trailingcontext lines.  This enables a calling process to resume a search.When.B grepstops after.I NUMmatching lines, it outputs any trailing context lines.  When the.B \-cor.B \-\^\-countoption is also used,.B grepdoes not output a count greater than.IR NUM .When the.B \-vor.B \-\^\-invert-matchoption is also used,.B grepstops after outputting.I NUMnon-matching lines..TP.B \-\^\-mmapIf possible, use the.BR mmap (2)system call to read input, instead ofthe default.BR read (2)system call.  In some situations,.B \-\^\-mmapyields better performance.  However,.B \-\^\-mmapcan cause undefined behavior (including core dumps)if an input file shrinks while.B grepis operating, or if an I/O error occurs..TP.BR \-n ", " \-\^\-line-numberPrefix each line of output with the line numberwithin its input file..TP.BR \-o ", " \-\^\-only-matchingShow only the part of a matching line that matches.I PATTERN..TP.BI \-\^\-label= LABELDisplays input actually coming from standard input as input coming from file.I LABEL.This is especially useful for tools like zgrep, e.g..B "gzip -cd foo.gz |grep --label=foo something".TP.BR \-\^\-line-bufferingUse line buffering, it can be a performance penality..TP.BR \-q ", " \-\^\-quiet ", " \-\^\-silentQuiet; do not write anything to standard output.Exit immediately with zero status if any match is found,even if an error was detected.Also see the.B \-sor.B \-\^\-no-messagesoption..TP.BR \-R ", " \-r ", " \-\^\-recursiveRead all files under each directory, recursively;this is equivalent to the.B "\-d recurse"option..TP.BR "\fR \fP \-\^\-include=" PATTERNRecurse in directories only searching file matching.I PATTERN..TP.BR "\fR \fP \-\^\-exclude=" PATTERNRecurse in directories skip file matching.I PATTERN..TP.BR \-s ", " \-\^\-no-messagesSuppress error messages about nonexistent or unreadable files.Portability note: unlike \s-1GNU\s0.BR grep ,traditional.B grepdid not conform to \s-1POSIX.2\s0, because traditional.B greplacked a.B \-qoption and its.B \-soption behaved like \s-1GNU\s0.BR grep 's.B \-qoption.Shell scripts intended to be portable to traditional.B grepshould avoid both.B \-qand.B \-sand should redirect output to /dev/null instead..TP.BR \-U ", " \-\^\-binaryTreat the file(s) as binary.  By default, under MS-DOS and MS-Windows,.BR grepguesses the file type by looking at the contents of the first 32KBread from the file.  If.BR grepdecides the file is a text file, it strips the CR characters from theoriginal file contents (to make regular expressions with.B ^and.B $work correctly).  Specifying.B \-Uoverrules this guesswork, causing all files to be read and passed to thematching mechanism verbatim; if the file is a text file with CR/LFpairs at the end of each line, this will cause some regularexpressions to fail.This option has no effect on platforms other than MS-DOS andMS-Windows..TP.BR \-u ", " \-\^\-unix-byte-offsetsReport Unix-style byte offsets.  This switch causes.B grepto report byte offsets as if the file were Unix-style text file, i.e. withCR characters stripped off.  This will produce results identical to running.B grepon a Unix machine.  This option has no effect unless.B \-boption is also used;it has no effect on platforms other than MS-DOS and MS-Windows..TP.BR \-V ", " \-\^\-versionPrint the version number of.B grepto standard error.  This version number shouldbe included in all bug reports (see below)..TP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -