Last active
September 29, 2015 14:28
-
-
Save rtfpessoa/1e5cd3cd1ddaab869217 to your computer and use it in GitHub Desktop.
Line counter dummy script
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 | |
EXTENSION=$1 | |
FILE_COUNT=0 | |
LINE_SUM=0 | |
for FILE in $(find . -type f -iname "*.$EXTENSION") | |
do | |
NUM_LINES=$(cat $FILE | wc -l) | |
NUM_LINES=${NUM_LINES%% } | |
NUM_LINES=${NUM_LINES## } | |
LINE_SUM=$((LINE_SUM + $NUM_LINES)) | |
FILE_COUNT=$((FILE_COUNT + 1)) | |
echo "File $FILE has $NUM_LINES lines" | |
done | |
AVERAGE_LINE_PER_FILE=$(($LINE_SUM / $FILE_COUNT)) | |
echo "Average line count is $AVERAGE_LINE_PER_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment