Last active
August 29, 2015 14:04
-
-
Save veewee/11859e7cf2364bf7b718 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# | |
# ./filecount-stats [dir1] [dir2] ... | |
# | |
TOTAL_FILES=0 | |
TOTAL_LINES=0 | |
for DIR in "$@" | |
do | |
echo "Reading $DIR" | |
DIR_FILES=$(tree "$DIR" | wc -l) | |
DIR_LINES=$(find "$DIR" -type f -exec wc -l {} \; | awk 'BEGIN{total = 0} {total += $1} END{print total}') | |
TOTAL_FILES=$(expr $TOTAL_FILES + $DIR_FILES) | |
TOTAL_LINES=$(expr $TOTAL_LINES + $DIR_LINES) | |
done | |
echo "Total Files: $TOTAL_FILES" | |
echo "Total lines: $TOTAL_LINES" | |
echo "Avg lines per file: $(expr $TOTAL_LINES / $TOTAL_FILES)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment