Hands-on task
awk: pivot on a key pair
In /root/sales.txt there are three fields: region, product, amount. Write an awk program in the file /root/pivot.awk (handy to do in the Editor tab above the terminal) that sums the amount by the (region, product) pair and prints lines region product amount. Run it with awk -f and write the result to /root/pivot.txt. The program will also be tested on other data. Line order doesn't matter.
- awk
- compound key
- aggregation
- associative arrays
- END block