Skip to content

Instantly share code, notes, and snippets.

@pyalot
Created August 24, 2013 06:37
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 pyalot/6326456 to your computer and use it in GitHub Desktop.
Save pyalot/6326456 to your computer and use it in GitHub Desktop.
Counts all files in the current directory recursively for each contained directory and outputs the count and directory name sorted numerically.
#!/usr/bin/env bash
function countFiles {
for i in $(pwd)/* ; do
if [ -d "$i" ]; then
echo $(find $i -type f | wc -l) $i
fi
done
}
countFiles | sort -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment