grep与egrep命令

greo -E 等同于 egrep

grep常用两种方式

1.   grep -c python a.txt

2.   cat a.txt | grep -c python

a.txt文件如下

i love python
i love python
i love python
i lovelove python
i love pythond
i love PYTHON
i love java

grep python a.txt 匹配包含python的行

grep -i python a.txt 匹配不包含python的行

grep -c python a.txt 只显示匹配到行总数

grep -i python a.txt 不区分大小写

grep -E 'python|java' a.txt 支持拓展正则表达式

更详细教程:https://www.cnblogs.com/crazymagic/p/11071876.html

原文地址:https://www.cnblogs.com/soymilk2019/p/11841782.html