shell 文本处理三剑客之 grep 和 egrep
shell 三剑客之 grep
命令语法格式

grep 参数

案例

显示file中有python的行
grep python file

显示没有python的行,不忽略大小写
grep -v python file

没有python的行,忽略大小写
grep -vi python file

查找/etc/man_db.conf 中带man的行,在文件中的行号
grep -n man /etc/man_db.conf

-E 支持扩展正则表达式选项 查找 python 或者 PYTHON 的行
grep -E "python|PYTHON" file

只显示匹配到的行数
grep -c python file

egrep 比 grep 功能更加强大,支持正则,其余的用法一样
egrep "python|PYTHON" file


浙公网安备 33010602011771号