源码计数Linux 源码计数脚本
PS:今天上午,非常郁闷,有很多简单基础的问题搞得我有些迷茫,哎,代码几天不写就忘。现在又不当COO,还是得用心记代码哦!
judge_your_input()
{
if [ -z $1 ] ; then
echo "please input your want count dir!"
echo ""
echo "example:"
echo "./back_file ./"
echo "like this example"
echo ""
exit
fi
}
judge_your_input $1
C_file_linescount=$(find $1 -name "*.c" |xargs cat|grep -v ^$|wc -l)
CPP_file_linescount=$(find $1 -name "*.cpp" |xargs cat|grep -v ^$|wc -l)
INCLUDE_file_linescount=$(find $1 -name "*.h" |xargs cat|grep -v ^$|wc -l)
UI_file_linescount=$(find $1 -name "*.ui" |xargs cat|grep -v ^$|wc -l)
QSS_file_linescount=$(find $1 -name "*.qss" |xargs cat|grep -v ^$|wc -l)
JAVA_file_linescount=$(find $1 -name "*.java" |xargs cat|grep -v ^$|wc -l)
echo "c file count = "$C_file_linescount
echo "cpp file count = "$CPP_file_linescount
echo "inc file count = "$INCLUDE_file_linescount
echo "ui file count = "$UI_file_linescount
echo "qss file count = "$QSS_file_linescount
echo "java file count = "$JAVA_file_linescount
total=$[$C_file_linescount+$CPP_file_linescount+$INCLUDE_file_linescount+$UI_file_linescount+$QSS_file_linescount+$JAVA_file_linescount]
echo "The total = "$total
这是一个我根据网上Linux 源码计数改良后实现的一个shell 脚本
它可以对你指定目录下的源码停止计数, 并且不记录空行数。我这里只记录了 *.c *.cpp 等我自己常用的源码类型。你可以对记录源码类型停止修改。
运行方法为:
./linescount.sh ./
输出为:
cfile count = 1832
cppfile count = 4726
incfile count = 1736
uifile count = 1715
qssfile count = 3379
javafile count = 0
The total =13388
所以可以看到现在我写的源码总共有 13388 行。
文章结束给大家分享下程序员的一些笑话语录:
程序员打油诗
写字楼里写字间,写字间里程序员;
程序人员写程序,又拿程序换酒钱。
酒醒只在网上坐,酒醉还来网下眠;
酒醉酒醒日复日,网上网下年复年。
但愿老死电脑间,不愿鞠躬老板前;
奔驰宝马贵者趣,公交自行程序员。
别人笑我忒疯癫,我笑自己命太贱;
不见满街漂亮妹,哪个归得程序员。
---------------------------------
原创文章 By
源码和计数
---------------------------------

浙公网安备 33010602011771号