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
Shell脚本统计C文件行数
本文介绍了一个Shell脚本,该脚本能够遍历指定目录及其子目录下的所有.c文件,并统计每个文件的行数。此外,脚本还记录了总的文件数量和总的行数。
608

被折叠的 条评论
为什么被折叠?



