grep命令参数:
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE.
Example: grep -i 'hello world' menu.h main.c
Pattern selection and interpretation:
-E, --extended-regexp PATTERN is an extended regular expression
-F, --fixed-strings PATTERN is a set of newline-separated strings
-G, --basic-regexp PATTERN is a basic regular expression (default)
-P, --perl-regexp PATTERN is a Perl regular expression
-e, --regexp=PATTERN use PATTERN for matching
-f, --file=FILE obtain PATTERN from FILE
-i, --ignore-case ignore case distinctions
-w, --word-regexp force PATTERN to match only whole words
-x, --line-regexp force PATTERN to match only whole lines
-z, --null-data a data line ends in 0 byte, not newline
Miscellaneous:
-s, --no-messages suppress error messages
-v, --invert-match select non-matching lines
-V, --version display version information and exit
--help display this help text and exit
Output control:
-m, --max-count=NUM stop after NUM selected lines
-b, --byte-offset print the byte offset with output lines
-n, --line-number print line number with output lines
--line-buffered flush output on every line
-H, --with-filename print file name with output lines
-h, --no-filename suppress the file name prefix on output
--label=LABEL use LABEL as the standard input file name prefix
-o, --only-matching show only the part of a line matching PATTERN
-q, --quiet, --silent suppress all normal output
--binary-files=TYPE assume that binary files are TYPE;
TYPE is 'binary', 'text', or 'without-match'
-a, --text equivalent to --binary-files=text
-I equivalent to --binary-files=without-match
-d, --directories=ACTION how to handle directories;
ACTION is 'read', 'recurse', or 'skip'
-D, --devices=ACTION how to handle devices, FIFOs and sockets;
ACTION is 'read' or 'skip'
-r, --recursive like --directories=recurse
-R, --dereference-recursive likewise, but follow all symlinks
--include=FILE_PATTERN search only files that match FILE_PATTERN
--exclude=FILE_PATTERN skip files and directories matching FILE_PATTERN
--exclude-from=FILE skip files matching any file pattern from FILE
--exclude-dir=PATTERN directories that match PATTERN will be skipped.
-L, --files-without-match print only names of FILEs with no selected lines
-l, --files-with-matches print only names of FILEs with selected lines
-c, --count print only a count of selected lines per FILE
-T, --initial-tab make tabs line up (if needed)
-Z, --null print 0 byte after FILE name
Context control:
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
-NUM same as --context=NUM
--color[=WHEN],
--colour[=WHEN] use markers to highlight the matching strings;
WHEN is 'always', 'never', or 'auto'
-U, --binary do not strip CR characters at EOL (MSDOS/Windows)
When FILE is '-', read standard input. With no FILE, read '.' if
recursive, '-' otherwise. With fewer than two FILEs, assume -h.
Exit status is 0 if any line is selected, 1 otherwise;
if any error occurs and -q is not given, the exit status is 2.
grep命令参数中文:
用法: grep [OPTION]... PATTERN [FILE]...
在每个文件中搜索符合模式的内容。
实例: grep -i 'hello world' menu.h main.c
范本样式选择和解释:
-E, --extended-regexp 范本样式是一个拓展的正则表达式
-F, --fixed-strings 范本样式是一个以换行符分割的字符串集合
-G, --basic-regexp 范本样式是一个普通的正则表达式 (默认)
-P, --perl-regexp 范本样式是一个Perl正则表达式
-e, --regexp=PATTERN 使用范本样式进行匹配
-f, --file=FILE 从指定文件中获取需匹配的范本样式
-i, --ignore-case 忽略字符大小写的区别
-w, --word-regexp 只显示全字符合的内容
-x, --line-regexp 只显示全列符合的内容
-z, --null-data 一个数据行以0字节结尾,而不是换行符
其他参数:
-s, --no-messages 禁用输出错误信息
-v, --invert-match 选择不匹配的行
-V, --version 显示版本信息并退出
--help 显示帮助信息并退出
输出控制:
-m, --max-count=NUM 在NUM行后停止输出
-b, --byte-offset 在输出行之前输出字节偏移量
-n, --line-number 在输出行之前输出行号
--line-buffered 在每一行输出后清空缓存
-H, --with-filename 在输出行前打印文件名
-h, --no-filename 禁用在输出中输出文件名前缀
--label=LABEL 使用LABEL作为标准输出文件名前缀
-o, --only-matching 只显示匹配样本范式的行
-q, --quiet, --silent 禁用所有的输出
--binary-files=TYPE 设定二进制文件类型为TYPE;
TYPE 是 'binary', 'text', 或'without-match'
-a, --text 等同于 --binary-files=text
-I 等同于 --binary-files=without-match
-d, --directories=ACTION 如何处理目录;
ACTION 是'read', 'recurse', 或'skip'
-D, --devices=ACTION 如何处理设备,有名管道,和套接字
ACTION 是 'read' 或 'skip'
-r, --recursive 类似 --directories=recurse
-R, --dereference-recursive 类似于'-r'与'-d recurse', 但是使用符号链接
--include=FILE_PATTERN 仅搜索匹配文件范本样式的文件
--exclude=FILE_PATTERN 跳过匹配文件范本样式的目录和文件
--exclude-from=FILE 跳过匹配任意指定文件中包含的文件范本样式文件
--exclude-dir=PATTERN 跳过匹配范本样式的目录
-L, --files-without-match 列出文件内容不符合指定的范本样式的文件名称
-l, --files-with-matches 列出文件内容符合指定的范本样式的文件名称
-c, --count 计算每个文件符合范本样式的行数
-T, --initial-tab 标签对齐
-Z, --null 在文件名后输出0字节
上下文控制:
-B, --before-context=NUM 显示匹配行前面NUM行
-A, --after-context=NUM 显示匹配行后面NUM行
-C, --context=NUM 显示输出行前后NUM行
-NUM 等同于 --context=NUM
--color[=WHEN],
--colour[=WHEN] 使用标记来突出匹配字符串;
WHEN 是 'always', 'never', 或 'auto'
-U, --binary 不要在换行符中去掉回车字符 (MSDOS/Windows)
当FILE为'-', 为标准输入。 没有指定FILE, 读去 '.'(当前文件夹)。