C source lines in file

Dave Decot decot at hpisod2.HP.COM
Mon Aug 14 07:37:57 AEST 1989


# cloc - count lines of code

for i in $*
do
    blanklines=`grep "^[ 	]*$" $i | wc -l`
    loc=`sed -e "s/^#.*/k/" $i | /lib/cpp | sed -e "/^[	 ]*$/d" -e 1d | wc -l`
    alllines=`cat $i | wc -l`
    commentlines=`echo $alllines - $blanklines - $loc | bc`
    echo $i \	CODE  $loc \	COMMENTS  $commentlines \	TOTAL  $alllines
done



More information about the Comp.lang.c mailing list