Last active
October 5, 2015 19:47
-
-
Save Alxandr/2865430 to your computer and use it in GitHub Desktop.
A short shell-script that is used to count lines of files given one or more file-sufixes.
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/bash | |
#Example use: count_files.sh cs xml // counts lines in *.cs and *.xml recursivly. | |
set -e | |
FILES="$@" | |
for f in $FILES; do | |
echo -ne "*.$f " | |
find . -name "*.$f" | | |
while read file; do | |
wc -l "$file" | | |
awk '{print $1}'; | |
done | | |
awk 'BEGIN { l = 0; s = 0 } {l+=$1} {s+=1} END {print s, l}' | |
done | | |
awk '{f+=$2} {l+=$3} {print $1.":\n Files:", $2."\n Lines:", $3."\n"} END {print "\n=================\n\nTotal:\n Files:",f,"\n Lines:",l}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment