Last active
April 24, 2022 18:48
-
-
Save StefanHeng/7a08209349a78b5372dcfac49a3271c4 to your computer and use it in GitHub Desktop.
Bash script for counting the number of files in each subdirectory
This file contains 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
ls_fl_count () { | |
max_len=-1 | |
for key in *; do | |
len=${#key} | |
((len > max_len)) && max_len=$len | |
done | |
pad=$((max_len + 5)) | |
fmt="%-${pad}s %s\n" | |
for i in *; do | |
printf "$fmt" "$i" "$(find "$i" | wc -l)"; | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment