分组排序的功能实现

cat */* | awk -F'|' '{++S[$3];C[$3]+=$4} END{for(a in S) print S[a],"\t",C[a],"\t",a}' | sort -nr

此shell可用于查询日志类的数据

需要按指定列分组并汇总分组的数据并排序,类似于sql中的

SELECT COUNT(money) AS totalCost FROM user_consume GROUP BY username ORDER BY num DESC

此sql可按用户汇总消费并按用户消费总额排序