linux下源码行数统计脚本
(非递归)
#!/bin/bash w=0 for s in $( find . -name *.[hc] ) do t=$( wc -l $s | awk '{print $1}' ) let "w=w+t" done echo $w
(递归) 
#!/bin/bash f() { w=0 for s in $( ls $1 ) do if [ -f $1 ] then let "w+=$(wc -l <$1)" break fi st=${s%/*} if [ -d $1/$st ] then let "w+=$(f $1/$st)" else case $st in *.c|*.h) let "w+=$(wc -l <"$1/$st")" ;; esac fi done echo $w } if [ -z "$1" ] then echo "Uasge:count_code path!" exit 1 else f $1 fi