Linux Shell Scripting Cookbook(Third Edition)
上QQ阅读APP看书,第一时间看更新

Counting the number of lines of C code in a source code directory

At some point, most programmers need to count the Lines of Code (LOC) in their C program files The code for this task is as follows:

$ find source_code_dir_path -type f -name "*.c" -print0 | xargs -0 wc -l 
If you want more statistics about your source code, a utility called SLOCCount, is very useful. Modern GNU/Linux distributions usually have packages or you can get it from http://www.dwheeler.com/sloccount/.