Created
August 14, 2012 01:02
-
-
Save skyscribe/3345296 to your computer and use it in GitHub Desktop.
Filter cloc result for a certain folder and get statistic information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for folder in `ls -l | grep "^d" | awk '{print $NF}'`;do | |
echo "counting lines for folder $folder" >> cloc.txt; | |
cloc.pl $folder >> cloc.txt; | |
done | |
filterCloc.awk cloc.txt > cloc_summary.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/awk -f | |
/counting lines for folder/{ | |
#print "current domain is", current_domain | |
current_domain = $NF | |
} | |
/^C\+\+ /{ | |
code_stats[current_domain, "c++"] = $NF | |
} | |
/^C /{ | |
code_stats[current_domain, "c source"] = $NF | |
} | |
/^C\/C\+\+ Header /{ | |
code_stats[current_domain, "header"] = $NF | |
} | |
/^(make|CMake) /{ | |
code_stats[current_domain, "make"] += $NF | |
} | |
END{ | |
printf("%-40s %-10s %10s\n", "domain", "type", "loc"); | |
previous_domain = ""; | |
domain_total = 0; | |
all_total = 0; | |
n = asorti(code_stats, new_stat) | |
for (i = 1; i <= n; i++){ | |
detail = new_stat[i] | |
split(detail, indexes, SUBSEP); | |
domain = indexes[1] | |
type = indexes[2] | |
loc = code_stats[detail] | |
if (domain != previous_domain){ | |
printf("%-40s %-10s %10d\n", previous_domain, "total", domain_total); | |
printf("------------------------------------------------------------------\n"); | |
all_total = all_total + domain_total | |
domain_total = 0; | |
} | |
printf("%-40s %-10s %10d\n", domain, type, loc); | |
domain_total = domain_total + loc | |
previous_domain = domain | |
} | |
printf("%-40s %-10s %10d\n", previous_domain, "total", domain_total); | |
printf("------------------------------------------------------------------\n"); | |
printf("%-40s %-10s %10d\n", "ALL DOMAINS", "total", all_total); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Key points:
asorti