#!/bin/bash # count # Count lines of code in a file, returning in order: # total lines of code, non-blank, non-comment lines of code, blank lines of code # # Any #ifdefs etc which can be expanded are, but #includes are not included. # temp=`mktemp /tmp/countXXXX` cat "$1" | sed -e "s/#include/donotinclude/g" > $temp echo -n LOC `cat $temp | wc -l` echo -n \ NBNC `cpp $temp | sed -e "s/^#.*$//g" | sed -e "/^$/d" | wc -l` echo \ Blank `egrep "^$" $temp | wc -l`