fgrep -x path/to/file1 path/to/file2 - 【重要】Count the number of lines that match the given string in a file: fgrep -c search_string path/to/file - Show the line number in the file along with the line matched: fgrep -n search_string path/to/file - Display all lines except th...
在下面的例子中,搜索全部以“lines”开始以“empty”结束的字串,如搜索“lines[之间任意字]empty” ,并且忽略大小写。 $ grep -i "lines.*empty" demo_file Two lines above this line is empty. 正则表达式遵循的几个重复的操作 最多匹配一次 * 匹配零次或者任意多次 + 匹配一次以上 {n} 匹配n次 {n,}...
-v, --invert-match Invert matching. Show lines that do not match the given patterns. -w, --word-regexp Only show matches surrounded by word boundaries. This is roughly equivalent to putting \b before and after all of the search patterns. -x, --line-regexp Only show matches surrounded ...
-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 matches -b, --byte-offset print the byte offset with output lines...
-m,--max-count=NUM stop after NUM matches-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 the file name for each match-h,--no-filename suppress the file na...
--M --merge-lines. 合并匹配的行 --orderly-match -O 通过输入的--grep参数,顺序匹配,顺序和输入--grep参数不一致则不匹配 --full-match. --grep全部匹配,则匹配成功 --print-group 可以通过主个参数,将整组日志打印,在前期问题诊断时非常有用。比如: ggrep --smart-logid --grep '某接口入参' --...
后n行,A记忆为(After) -B n 前n行,B记忆为(Before) -C n 前n行,后n行,C记忆为(Center) 举例 [root@localhost ~]# ifconfig | grep -A 2 "Link encap" eth0 Link encap:Ethernet HWaddr 00:0C:29:F3:38:15 inet addr:192.168.91.129 Bcast:192.168.91.255 Mask:255.255.255.0 ...
-v, --invert-match:显示不能被模式匹配到的行; -E:支持使用扩展的正则表达式元字符; -q, --quiet, --silent:静默模式,即不输出任何信息; -A #:after, 后#行 -B #:before,前#行 -C #:context,前后各#行 ...
Print 3 lines of context around, before, or after each match: grep --context|before-context|after-context 3 "search_pattern" path/to/file Print file name and line number for each match with color output: grep -H|--with-filename -n|--line-number --color=always "search_pattern" path/...
Instead of showing every matched line, show the number of lines that match. --color[=<when>] Show colored matches. The value must be always (the default), never, or auto. --no-color Turn off match highlighting, even when the configuration file gives the default to color output. Same ...