这是我统计代码量时碰到的一个问题。不管我敲了多少代码,用老师上学期的那个脚本统计的代码量始终为0。回去问了同窗,了解到上学期的脚本只能用来统计Java的代码量。由于它统计的后缀是.java,而咱们这学期的学习与C相关,所以,咱们只需将.java改成.c便可。html
#!/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 "