shell查询.c文件行数,源码
read dir
dirpath=$1
m=$1
a=0
b=0
c=0
d=0
IsC()
{
if [[ $1 == *.c* ]]; then
return 1
else
return 0
fi
}
function read_dir() {
for file in `ls $1`
do
echo 文件名字---》$1"/"$file
if [ -d $1/$file ];then
let a++
echo a = $a
cd $1/$file
read_dir $1"/"$file
else
if test -f $file ; then
let b++
echo b = $b
IsC $file
if [ $? -eq 1 ];then
declare -i mm
mm=`sed -n '$=' $1"/"$file `
echo " $1"/"$file ----------$mm"
let d=($d + $mm)
fi
fi
echo $file
fi
done
}
read_dir $dir
echo $d