统计代码行数的实用脚本

每次快到年底的时候各种的审计工作都在进行中,而最近应为部门需要统计个人写的代码有多少为此,为了方便统计就写了一个脚本用于统计代码的行数,脚本如下:

#!/bin/bash
#count.sh
#Use Count the number of lines of code
#writer jim
#history
#2017.02.06
if [ $# -lt 1 ];then
        echo "please enter argc!"
        echo "ex> $0 path"
        exit 0
fi
 
if [ $# -gt 1 ]; then
    echo "too many input path!"
    echo "ex> $0 argc"
    exit 0
fi
 
path=$1
lines=`cat $(find $path -name '*.c' -o -name '*.sh' -print) | grep -v '^$' | wc -l`
echo "lines is : $lines"

这样通过简单的统计下就能快速的获取代码的行数。

猜你喜欢

转载自www.linuxidc.com/Linux/2017-02/140252.htm
今日推荐