1. 程式人生 > >Linux命令之grep用法

Linux命令之grep用法

Linux命令之grep用法

Usage: grep [OPTION]… PATTERN [FILE]…
用法: grep [選項]…模式 [檔案]。

Search for PATTERN in each FILE or standard input.
在每個檔案或標準輸入中搜索模式。
PATTERN is, by default, a basic regular expression (BRE).
預設情況下, 模式是基本正則表示式 (BRE)。
Example: grep -i ‘hello world’ menu.h main.c

Regexp selection and interpretation:
-E, --extended-regexp PATTERN is an extended regular expression

(ERE)
模式是擴充套件正則表示式 (ERE)
-F, --fixed-strings PATTERN is a set of newline-separated strings
模式是一組換行符分隔的字串
-G, --basic-regexp PATTERN is a basic regular expression (BRE)
模式是基本正則表示式 (BRE)
-P, --perl-regexp PATTERN is a Perl regular expression
模式是 Perl 正則表示式
-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

資料行以0位元組結尾, 而不是換行符