2012年6月1日 星期五

統計程式碼

想要統計程式行數,又是 bash 新手等級,查到好心網友的指令:
 find . \( -name *.h -or -name *.c \) -print

拿 linux source 來試試,沒問題。但是在我的 project 下,出現 error:
find: paths must precede expression: CADebugMacros.h

修正後可以了:
 find . \( -name '*.h' -or -name '*.c' \) -print

最後加上 wc :
 find . \( -name '*.h' -or -name '*.c' \) -exec cat "{}" ";" | wc -l 


1 則留言: