Linux統計項目代碼行數-wc
Usage: wc [OPTION]... [FILE]... -c, --bytes, --chars print the byte counts -l, --lines print the newline counts -L, --max-line-length print the length of the longest line -w, --words print the word counts --help display this help and exit --version output version information and exit
打開終端,用cd命令定位到工程所在的目錄,然后調用以下命名即可把每個源代碼文件行數及總數統計出來:
find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.rss" ")" -print | xargs wc -l
上面命令可以搜索這個工程。但包含了空格。
find . "(" -name "*c" -or -name "*.h" -or -name "*cpp" ")" -print | xargs wc -l
下面舉幾個例子:
1.統計當前目錄下,py文件數量:
find . -name "*.py" |wc -l
2.統計當前目錄下,所有py文件行數:
find . -name "*.py" |xargs cat|wc -l
3.統計當前目錄下,所有py文件行數,并過濾空行:
find . -name "*.py" |xargs cat|grep -v ^$|wc -l
*博客內容為網友個人發布,僅代表博主個人觀點,如有侵權請聯系工作人員刪除。
繼電器相關文章:繼電器工作原理
時間繼電器相關文章:時間繼電器