percentage.awk (346B)
1 #!/usr/bin/awk -f 2 # Copyright 2023 Jacob R. Edwards 3 # Takes the entries produced by costs.awk and gives the percentage 4 # each takes out of the sum of all. 5 6 BEGIN { 7 FS = " "; 8 OFS = FS; 9 OFMT = "%.2f" 10 } 11 12 { 13 names[NR] = $1; 14 values[$1] = $2; 15 total += $2; 16 } 17 18 END { 19 div = total / 100; 20 for (i in names) 21 print names[i], values[names[i]] / div; 22 }