【grep 和 egrep】
shell 三剑客之 grep
命令语法格式

grep 参数

案例

显示file中有python的行
|
1
|
grep python file |

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

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

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

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

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

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


浙公网安备 33010602011771号