我有以下数据名为atp.csv file
Date_Time,M_ID,N_ID,Status,Desc,AMount,Type
2015-01-05 00:00:00 076,1941321748,BD9010423590206,200,Transaction Successful,2000,PRETOP
2015-01-05 00:00:00 077,1941323504,BD9010423590207,351,Transaction Successful,5000,PRETOP
2015-01-05 00:00:00 078,1941321743,BD9010423590205,200,Transaction Successful,1500,PRETOP
2015-01-05 00:00:00 391,1941323498,BD9010500000003,200,Transaction Successful,1000,PRETOP
我想使用以下命令计算状态。
cat atp.csv|awk -F',' '{print $4}'|sort|uniq -c
输出如下:
3 200
1 351
但我想在下面输出...
200,3
351,1
状态是先行,然后计算值。
答案 0 :(得分:1)
您可以再次使用awk交换列:
awk -F, '{print $4}' atp.csv | sort | uniq -c | awk '{print $2","$1}'