How do I find files that do not contain a given string pattern?

后端 未结 16 1328
半阙折子戏
半阙折子戏 2020-11-28 17:42

How do I find out the files in the current directory which do not contain the word foo (using grep)?

16条回答
  •  一个人的身影
    2020-11-28 18:13

    another alternative when grep doesn't have the -L option (IBM AIX for example), with nothing but grep and the shell :

    for file in * ; do grep -q 'my_pattern' $file || echo $file ; done
    

提交回复
热议问题