常用脚本
1 2 3 4 5 6 7 8 9 10
| echo "统计文件中代码行数" c1=$(find -name "*.cpp" | wc -l) h1=$(find -name "*.h" | wc -l) echo "文件个数:$(expr ${c1} + ${h1}),*.cpp:${c1},*.h:${h1}" c2=$(find -name "*.cpp" | xargs cat | wc -l) h2=$(find -name "*.cpp" | xargs cat | wc -l) echo "总行数:$(expr ${c2} + ${c2}),*.cpp:${c2},*.h:${h2}" c3=$(find -name "*.cpp" | xargs cat | grep -v ^$| wc -l) h3=$(find -name "*.cpp" | xargs cat | grep -v ^$| wc -l) echo "去掉空格行数:$(expr ${c3} + ${c3}),*.cpp:${c3},*.h:${h3}"
|
set
1 2 3 4
| set -e set -u set -x set -o pipefail
|
参考文献
[cat << EOF]https://www.jianshu.com/p/df07d8498fa5
Bash 脚本 set 命令教程