Last active
August 29, 2015 14:01
-
-
Save rjchatfield/37c9d09660faffa90611 to your computer and use it in GitHub Desktop.
Count the number of lines of code so you can prove to your manager that you're worth that pay rise
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
# Count the number of lines of code | |
lineCount() | |
{ | |
file_types=(h m hpp cpp java html js css scss py rb php sql) | |
integer totallc=0 | |
integer totalfc=0 | |
echo | |
echo '=======================' | |
echo "== CODE LINE COUNTER ==" | |
echo '=======================' | |
echo | |
echo ' TYPE FILES LINES' | |
echo '-----------------------' | |
for f in $file_types; do | |
# Do a file count | |
fc=$( ( find **/*.${f} -type f | wc -l ) 2> /dev/null ) | |
# If there is a value for fc | |
# (which means there were files of that type) | |
# print to screen | |
if ! [[ $fc -eq 0 ]]; then | |
# Do a line count (ignore error messages), | |
# | get the last line of output, | |
# | and get the first element of that line | |
lc=$( ( wc -l **/*.${f} ) 2> /dev/null | tail -1 | awk '{print $1;}' ) | |
printf '%7s %7d %7d\n' '.'${f} $fc $lc | |
totallc+=$lc | |
totalfc+=$fc | |
fi | |
done | |
echo '-----------------------' | |
printf '%7s %7d %7d\n' 'total' $totalfc $totallc | |
echo '=======================' | |
echo | |
} | |
alias lc='lineCount' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment