统计目录下C代码的总行数

#!/bin/sh

#
# Line Counter
#
# Usage: lcnt dir suffix1, suffix2, suffix3 ...
#


v_dir="$1"
v_linenum=0

if [ $# = 0 ]; then
    echo "============================================="
    echo "Usage: lcnt dir suffix1 suffix2 suffix3 ...  "
    echo "Usage: lcnt dir                              "
    echo "============================================="
elif [ $# = 1 ]; then
    v_linenum=$(find $v_dir -type f | xargs -i cat {} | wc -l)
    echo "Total: "$v_linenum
else
    while [ "$2" != "" ]; do
        v_linenum=$(find $v_dir -type f -name "*$2" | xargs -i cat {} | wc -l)
        echo "*$2: "$v_linenum
        shift
    done
fi

exit 0

你可能感兴趣的:(C++,c,C#,F#,idea)