Last active
October 18, 2017 05:19
-
-
Save astyagun/34fc441125443568617d1b1d41f1509c to your computer and use it in GitHub Desktop.
Count files in first level subdirectories of a given directory, sort results by fins count in descending order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -d "$1" ]; then | |
echo \"$1\" is not a directory | |
exit 1 | |
fi | |
find "$1" -type d -maxdepth 1 | xargs -I{} sh -c 'echo `find {} -type f | wc -l` {}' | sort -nr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment