This is the output snippet of cloc command
C/C++ Header
same 0 0 42812 19019
modified 33 0 128 434
added 3 63 367 207
removed 0 105 265 479
Perl
same 0 0 0 0
modified 0 0 0 0
added 2 0 0 0
removed 0 0 0 0
-------------------------------------------------------------------------------
SUM:
same 0 0 54150 81007
modified 82 0 252 2137
added 7 184 802 1281
removed 0 234 734 1499
-------------------------------------------------------------------------------
Using Shell command, how to print only 82, 2137 (in row modified) and 7, 1281(in row added) ? I need to print only these 4 numbers under "SUM:" and ignore the rest.
If you want to get the number of added/modified files/lines between two versions of a project, you can do it correctly and robustly with cloc's XML output:
cloc --xml --out=report.xml --diff bash-4.2.tar.gz bash-4.3.tar.gz
xmlstarlet < report.xml sel -t \
-m /diff_results/modified/total -v @sum_files -o ' ' -v @code -nl \
-m /diff_results/added/total -v @sum_files -o ' ' -v @code -nl
xmlstarlet can output the numbers in any format you want. This specific example uses this format (modified files/lines followed by added files/lines):
15 11157
203 6058
The benefit of processing computer readable output rather than human readable output is that it won't break if cloc slightly changes its output formatting in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With