[英]grep the files that contain specific word and don't contain those words
我需要使用grep命令来获取所有包含[form]单词的文件,并且不要同时包含[head]或[cfGenerate]单词。
GNU grep with PCRE : 使用PCRE的GNU grep:
grep -P '^(?!.*head)(?!.*cfGenerate).*form'
negative lookaheads can be combined to make the match fail if any unwanted pattern occurs. 如果出现任何不需要的模式,则可以组合使用否定的超前行为使匹配失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.