美文网首页
grep 命令使用

grep 命令使用

作者: 冰舞one | 来源:发表于2018-12-08 18:17 被阅读0次

grep 过滤

参数:-v -B -C  -A 使用

grep 参数:-i -o  -E (正则)与egrep等 

grep 参数-w 精准匹配查找的内容并输出所在行

[root@localhost scripts]#cat sedtext

qwerrrr

wewq

wew1

erw

wew

[root@localhost scripts]#grep "wew" sedtext

wewq

wew1

wew

[root@localhost scripts]#grep  -w "wew" sedtext

wew

grep -n ".*" 显示行号输出 “.*” 代表任意字符

[root@localhost scripts]#grep  -n ".*" sedtext

1:qwerrrr

2:

3:wewq

4:wew1

5:erw

6:wew wweweweefd

7:wew weww

8:wew

grep -E 或egrep 可以使用正则表达

[root@localhost scripts]#egrep  -w "wew|fds" sedtext

wew wweweweefd

wew weww

wew

fds

相关文章

网友评论

      本文标题:grep 命令使用

      本文链接:https://www.haomeiwen.com/subject/urzqhqtx.html