Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@crwolff
Created August 31, 2020 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crwolff/11de27d14a34cc47557f4fe287c553af to your computer and use it in GitHub Desktop.
Save crwolff/11de27d14a34cc47557f4fe287c553af to your computer and use it in GitHub Desktop.
Find all directories containing only certain files (from SO)
find . -type d -exec bash -O dotglob -c '
for dirpath do
ok=true
seen_files=false
set -- "$dirpath"/*
for name do
[ -d "$name" ] && continue # skip dirs
seen_files=true
case "${name##*/}" in
*.tmp|desktop.ini|Thumbs.db|.picasa.ini) ;; # do nothing
*) ok=false; break
esac
done
"$seen_files" && "$ok" && printf "%s\n" "$dirpath"
done' bash {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment