简体   繁体   中英

grep the files that contain specific word and don't contain those words

我需要使用grep命令来获取所有包含[form]单词的文件,并且不要同时包含[head]或[cfGenerate]单词。

GNU grep with PCRE :

grep -P '^(?!.*head)(?!.*cfGenerate).*form'

negative lookaheads can be combined to make the match fail if any unwanted pattern occurs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM