I have a directory named dir1
which has about 800 sub-directories named disp-001, disp-002, ... disp-800
. I need to find sub-directories that
- either do not contain a file
stdout
or - if they do, that file does not contain a particular string
str1
.
Identifying sub-directories that do not contain the file is answered in another question
$ find . -type d \! -exec test -e '{}/stdout' \; -print
However if I try to include grep in the above command, it does not work
$ find . -type d \! -exec test -e 'grep str1 {}/stdout' \; -print
How can I include the string search to return me the directory of interest?