使用脚本统计代码行数

发布时间 2024-01-06 13:09:58作者: 20201327刘谨铭

代码

#!/bin/sh
clear
echo "//==========Today====================================="
echo "code summary infomation:"
find . -name "*.c" -mtime 0 | xargs cat | grep -v ^$ | wc -l 
echo "documents summary infomation:"
find . -name "*.md" -mtime 0 | xargs cat | grep -v ^$ | wc -l 
echo ""

echo "//==========This Week================================="
echo "code summary infomation:"
find . -name "*.c" -mtime -7| xargs cat | grep -v ^$ | wc -l 
echo "do#!/bin/sh
clear
echo "//==========Today====================================="
echo "code summary infomation:"
find . -name "*.c" -mtime 0 | xargs cat | grep -v ^$ | wc -l 
echo "documents summary infomation:"
find . -name "*.md" -mtime 0 | xargs cat | grep -v ^$ | wc -l 
echo ""

echo "//==========This Week================================="
echo "code summary infomation:"
find . -name "*.c" -mtime -7| xargs cat | grep -v ^$ | wc -l 
echo "documents summary infomation:"
find . -name "*.md" -mtime -7| xargs cat | grep -v ^$ | wc -l 
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-0 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-1 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-2 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-3 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-4 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-5 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-6 days"`
echo ""
echo ""

echo "//==========All================================="
echo "code summary infomation:"
find . -name "*.c"| xargs cat | grep -v ^$ | wc -l 
echo "documents summary infomation:"
find . -name "*.md"| xargs cat | grep -v ^$ | wc -l 
echo "commit history:"
git log --pretty=format:"%h - %an,%ci: %s "
cuments summary infomation:"
find . -name "*.md" -mtime -7| xargs cat | grep -v ^$ | wc -l 
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-0 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-1 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-2 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-3 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-4 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-5 days"`
git log --pretty=format:"%h - %an,%ci: %s " | grep  `date +%F --date="-6 days"`
echo ""
echo ""

echo "//==========All================================="
echo "code summary infomation:"
find . -name "*.c"| xargs cat | grep -v ^$ | wc -l 
echo "documents summary infomation:"
find . -name "*.md"| xargs cat | grep -v ^$ | wc -l 
echo "commit history:"
git log --pretty=format:"%h - %an,%ci: %s "


授予脚本执行权限:

chmod +x myscript.sh

运行脚本:

./myscript.sh

运行截图