Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Eddy-Barraud
Last active February 16, 2019 12:17
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 Eddy-Barraud/5e4120df03067731581aa87c9c293c7a to your computer and use it in GitHub Desktop.
Save Eddy-Barraud/5e4120df03067731581aa87c9c293c7a to your computer and use it in GitHub Desktop.
List folders by the number of files inside of it, recursively

This one line command will list each folders in current path by the number of files inside of it, recursively.

find . -type d -exec sh -c "fc=\$(find '{}' -type f | wc -l); echo \"\$fc\t{}\"" \; | sort -nr

For only one/specified level of recursion :

find . -maxdepth 1 -type d -exec sh -c "fc=\$(find '{}' -type f | wc -l); echo \"\$fc\t{}\"" \; | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment