Counting number of lines of code recursively

The following script counts the total number of lines of code in .c starting in the current directory and continuing in the subdirectories recursively.

#!/bin/sh
# countlines.sh
total=0
for currfile in $(find . -name "*.c" -print)
do
    total=$[total+($(wc -l $currfile| awk '{print $1}'))]
    echo -n 'total=' $total 
    echo -e -n '\r'
done
echo  'total=' $total

If you want to be able to count .h, .cc and .java files as well, modify the argument -name "*.c" to -name "*.[c|h|cc|java]"