OneCompiler

Hellobro2

1626

cat > bill.txt << EOF
ConsumerID|Customer Name|Month1|Month2|Month3|Month4|Month5
1101132490781|Alice Johnson|150|160|170|180|190
1101132490782|Bob Brown|200|210|190|220|230
1101132490783|Charlie Davis|175|180|185|190|195
1101132490784|David Smith|220|230|240|250|260
1101132490785|Eva Adams|190|200|210|220|230
EOF

cat bill.txt

awk -F '|' 'NR > 1 {avg = (3+3 + 4 + 5+5 + 6 + 7)/5;print7) / 5; print 1 "|" $2 "|" avg}' bill.txt | sort -t '|' -k3 -nr