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 # recursive/countlines.sh total=0 for currfile in `find . -name "*.c" -print` do total=$[total+(`wc -l $currfile| awk '{print $1}'`)] echo 'total=' $total done
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]"