gno/usr.bin/awk/tests/percent
tribby ddb82cb2e0 Remaining files for awk 2.0 that were left out of the previous checkin.
Maybe someday I'll become adept at using cvs...
1998-04-07 17:06:53 +00:00

11 lines
263 B
Plaintext

# percent
# input: a column of nonnegative numbers
# output: each number and its percentage of the total
{ x[NR] = $1; sum += $1 }
END { if (sum != 0)
for (i = 1; i <= NR; i++)
printf("%10.2f %5.1f\n", x[i], 100*x[i]/sum)
}