Skip to content

Instantly share code, notes, and snippets.

@emjayoh
Created February 4, 2021 06:09
Show Gist options
  • Save emjayoh/5da643677089db2be7fbc66c6ed3d95e to your computer and use it in GitHub Desktop.
Save emjayoh/5da643677089db2be7fbc66c6ed3d95e to your computer and use it in GitHub Desktop.
[Search/print bash] Print all directories where files satisfy condition
set -o extendedglob
has_useful_entries()
()(($#)) ${1-$REPLY}/^(#i)(*.tmp|desktop.ini|Thumbs.db|.picasa.ini)(NDoN[1])
printf '%s\n' **/*(D/F^+has_useful_entries)
set -o extendedglob # for ^ and (#i)
printf '%s\n' **/*(D/F^e'[()(($#)) $REPLY/^(#i)(*.tmp|desktop.ini|Thumbs.db|.picasa.ini)(ND)]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment