(九)、grep和egrep命令
作者:
雪燃归来 | 来源:发表于
2021-01-17 22:45 被阅读0次
语法
![](https://img.haomeiwen.com/i10349654/5417e9137945efb7.png)
grep语法
参数
![](https://img.haomeiwen.com/i10349654/64f65d305cea0a34.png)
grep参数
![](https://img.haomeiwen.com/i10349654/aeb1ab07b7366aea.png)
grep参数
![](https://img.haomeiwen.com/i10349654/3314116c48ecd069.png)
常用参数一览表
例子
// 在grep.txt中查找包含python的行
grep python grep.txt
// 按照正则表达式查找匹配行信息
grep "py.*" grep.txt
// ...不包含python的信息
grep -v python grep.txt
// ...忽略大小写匹配python信息
grep -iv pthon grep.txt
// 显示行号
grep -n python grep.txt
// 正则表达式
grep -E "python|PYTHON" grep.txt
// 按照字面意思匹配,非正则
grep -F "python|PYTHON" grep.txt
// 在当前目录下递归搜索 love
grep -r love grep.txt
// 查找匹配后的行号
grep -c python grep.txt
// 匹配整词
grep -w python grep.txt
// 匹配整行
grep -x "i love python" grep.txt
// egrep和grep -E 等价
egrep -n "python|PYTHON" grep.txt
积累
// 连续创建多级目录
mkdir test1/test2/test3 -pv
本文标题:(九)、grep和egrep命令
本文链接:https://www.haomeiwen.com/subject/lcizaktx.html
网友评论