[root@localhost script]# grep -b 'centos' userfile.txt -b (block) #在搜索到的行的前面打印该行所在的块号码;
0:centos1
8:centos 2
17:centos3
[root@localhost script]# grep -n 'centos' userfile.txt -n #在每行前面列出行数
1:centos1
2:centos 2
3:centos3
[root@localhost script]# grep -c 'centos' userfile.txt -c #只显示有行匹配行的整数
3
[root@localhost script]# grep -i 'world' userfile.txt -i #在字符串比较的时候忽略大小写
WORLD
world 1
world 3
6 world
world
-v 反检索,只显示不匹配的行
grep -v 'centos' userfile.txt
...
/
-h #不显示文件名
-l 只显示包含匹配模板的行的文件名清单
-L 与-l 结果相反,取反
-f 从文件file中提取模板