欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

包含与不包含 排除 有大用

 -v, --invert-match  排除

              Invert the sense of matching, to select non-matching lines.


# -P, --perl-regexp    #将模式解释为Perl正则表达式。

              Interpret PATTERN as a Perl regular expression.


[root@localhost ~]# cat aa.txt

11.jpg.php

22.jpg

33.jpg.aa.php

44.jpg.bb

55.php

66

[root@localhost ~]#  grep  -P '(?!.*jpg)php' aa.txt

11.jpg.php

33.jpg.aa.php

55.php


[root@localhost ~]#  grep -v  -P '(?!.*jpg)php' aa.txt

22.jpg

44.jpg.bb

66

[root@localhost ~]#


image.png

普通分类: