Find directories not containing some files

Here's my directory structure:

find .
.
./dir2
./dir2/file.pdf
./dir1
./dir1/file.zip
./dir3

Command:

find . -mindepth 1 -maxdepth 1 -type d | while read dir; do
  list=$(ls -1 $dir)
  if ! ( echo $list | egrep -qi "\.zip$|\.pdf$" ); then
   echo $dir
  fi
done

Output:

./dir3

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).