Fork me on GitHub

版权声明 本站原创文章 由 萌叔 发表
转载请注明 萌叔 | https://vearne.cc
#current directory
CURR_DIR='.'
if [ ! -z $1 ];then
CURR_DIR=$1
fi 
# create 3 tempory file to record detail infomation
find $CURR_DIR -name "*.cpp" | xargs wc -l > cpp_line_detail.txt
find $CURR_DIR -name "*.c" | xargs wc -l > c_line_detail.txt 
find $CURR_DIR -name "*.h" | xargs wc -l > h_line_detail.txt
#count
CPP_COUNT=$(tail -1  cpp_line_detail.txt | sed -e 's/^ *//' | sed -e 's/ .*$//')
C_COUNT=$(tail -1  c_line_detail.txt | sed -e 's/^ *//' | sed -e 's/ .*$//')
H_COUNT=$(tail -1 h_line_detail.txt | sed -e 's/^ *//' | sed -e 's/ .*$//')
echo "The code in *.cpp files is "$CPP_COUNT" lines"
echo "The code in *.c files is "$C_COUNT" lines"
echo "The code in *.h files is "$H_COUNT" lines"
echo "------------------------------------"
#the final result
echo "The total number of lines is "$(($CPP_COUNT + $C_COUNT + $H_COUNT))

后记

这是我2012年的文章


请我喝瓶饮料

微信支付码

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注