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

这里的技术是共享的

You are here

【shell】正则表达式用法:匹配不包含字符串

1、参考

https://blog.csdn.net/soaringlee_fighting/article/details/80931295

https://blog.csdn.net/MYsce/article/details/76546480

https://blog.csdn.net/thewindkee/article/details/52785763


2、匹配不包含字符串 用法

方法一:

采用grep命令中的-v参数,可以搜索不包含指定字符的所有行。

e.g:


ls -lR ./OutResult/ | grep -e 'svac2$' -v 'QP' | wc -l

1

说明:上述命令表示列出outResult目录以及子目录下面以svac2结尾并且不包含字符串QP的所有行的行数。


方法二:


(?!abc) 

1

说明:表示不包含字符串abc


(?!pattern)负向预查,在任何不匹配 pattern 的字符串开始处匹配查找字符串。


同样实现方法一中功能:


ls -lR | grep -e '((?!QP).)svac2$' | wc-l

1

THE END!

--------------------- 

作者:SoaringLee_fighting 

来源:CSDN 

原文:https://blog.csdn.net/soaringlee_fighting/article/details/81196160 

版权声明:本文为博主原创文章,转载请附上博文链接!


来自  https://blog.csdn.net/soaringlee_fighting/article/details/81196160

普通分类: