Skip to content

Commit

Permalink
Make totals right-aligned and thousand-separated
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbarnes committed Jul 2, 2012
1 parent 835bf4b commit 70e512f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tally
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ stripxml() {
awk -vRS='-->' '{gsub(/<!--.*/,"")}1' $1 | sed '/^\s*$/d'
}

print() {
printf "%-8s %'8d\n" $*
}

count() {
case $2 in
awk|coffee|make|perl|python|sed|shell|tcl)
Expand Down Expand Up @@ -64,8 +68,8 @@ for F in $(find $@ -type f -not -path "*/.*"); do
done

for LANGUAGE in ${!SUB[@]}; do
printf "%-8s %d\n" $LANGUAGE: ${SUB[$LANGUAGE]}
print $LANGUAGE: ${SUB[$LANGUAGE]}
let TOTAL+=${SUB[$LANGUAGE]}
done

printf "%-8s %d\n" total: $TOTAL
print total: $TOTAL

0 comments on commit 70e512f

Please sign in to comment.