Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下平面文件,并想确定每个用户第一列中所有点的总和。例如:
50 user1 100 user2 10 user1 20 user3
会回来
60 user1 100 user2 20 user3
有可能做这个bash吗?
#!awk -f { foo[$2] += $1 } END { for (bar in foo) print foo[bar], bar }
awk '{a[$2]+=$1}END{for(i in a )print a[i],i}' your_file