- Linux Shell Scripting Cookbook(Third Edition)
- Clif Flynt Sarath Lakshman Shantanu Tushar
- 81字
- 2021-07-09 19:46:16
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/.