Wednesday, 28 September 2011

Associated Array in awk


Note that in awk, index can be string instead of traditional integer.
It is great and helpful feature of awk

Just to demonstrate, you can execute below one liner to get the total file size by user.
code to print total file size by users
 > ls -lR | awk '{users[$3]+=$5;} END { for (user in users) { print user, users[user] } }'

No comments:

Post a Comment