使用find和wc命令统计代码行数


It’s simple, suppose we want to count *.cpp and *.h, run this oneliner in the root directoy of your project:

find . \( -name '*.cpp' -o -name '*.h' \) -print0 | wc -l --files0-from=- | sort  -n

sample output:

➜  SchoolPersonnelMgmt git:(master) find . \( -name '*.cpp' -o -name '*.h' \) -print0 | wc -l --files0-from=- | sort -n
7 ./StudentFilterDialog.cpp
18 ./CommonSortFilterProxyModel.h
22 ./main.cpp
25 ./CommonSortFilterProxyModel.cpp
25 ./StudentTableDelegate.h
26 ./StudentFilterDialog.h
32 ./teachingassistant.h
35 ./const.h
43 ./teachingassistant.cpp
46 ./PostgraduateTableModel.h
46 ./TeacherTableModel.h
46 ./TeachingAssistantTableModel.h
48 ./teacher.cpp
49 ./StudentTableModel.h
50 ./postgraduate.cpp
56 ./student.h
66 ./teacher.h
68 ./mainwindow.h
71 ./postgraduate.h
78 ./person.cpp
88 ./student.cpp
142 ./StudentTableDelegate.cpp
148 ./person.h
198 ./PostgraduateTableModel.cpp
198 ./TeacherTableModel.cpp
198 ./TeachingAssistantTableModel.cpp
216 ./StudentTableModel.cpp
404 ./mainwindow.cpp
2449 total

本文地址:http://zisxks.com/2013/11/18/line-of-code-statistics-use-find-and-wc
分享到 Share: 0

欢迎转载,转载请注明作者及出处zisxks.com,请勿用于商业用途