根據用戶指定的模式(pattern),對目標文件進行過濾,顯示被漠視匹配到的行
格式:grep [參數] 匹配內容 [文件]
常用參數:
-v
:顯示未匹配到的行-i
:忽略大小寫-n
:顯示匹配的行號-c
:統計匹配的行數-o
:僅顯示匹配到的字符串-E
:使用 ERE,相當于 egrep
實戰應用:
$ cat test
root root hello root
new
new
root
root
leo
kate
hogwart
string
leon
$ grep -n root test
1:root root hello root
4:root
5:root
$ grep -vn root test
2:new
3:new
6:leo
7:kate
8:hogwart
9:string
10:leon
$ grep ^s -n test
9:string
$ grep n$ -n test
10:leon
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态