Skip to content

Instantly share code, notes, and snippets.

@pavgup
Last active December 21, 2015 15:55
Show Gist options
  • Save pavgup/9507202f4aa133901d1f to your computer and use it in GitHub Desktop.
Save pavgup/9507202f4aa133901d1f to your computer and use it in GitHub Desktop.
count files recursively in directories and sort results
find . -maxdepth 3 -noleaf -type d -exec sh -c "ls -ltaR \"{}\" | wc -l | tr \"\n\" \" \" && echo \"{}\"" \; | sort -n
# or more simply without a sort:
find . -type d -maxdepth 1 -print0 -exec sh -c 'find "{}" -type f | wc -l' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment