Skip to content

Instantly share code, notes, and snippets.

@rajsahae
Created September 20, 2013 00:28
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 rajsahae/6631781 to your computer and use it in GitHub Desktop.
Save rajsahae/6631781 to your computer and use it in GitHub Desktop.
Finding empty directiories in bash
for dir in `find . -type d | tail -n +2`; do
[ "`find $dir -type f | wc -l`" -eq "0" ] && echo "$dir is empty"
done
@rajsahae
Copy link
Author

I also used:

find . -type d -empty -delete

That seems to be way better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment