vieyahn2017 / shellv

shell command test and study
4 stars 1 forks source link

【5.15】shell命令实现group by功能 == sort | uniq -c #86

Open vieyahn2017 opened 1 year ago

vieyahn2017 commented 1 year ago

shell命令实现group by功能

vieyahn2017 commented 1 year ago

https://blog.51cto.com/u_15104381/2621904

vieyahn2017 commented 1 year ago

1、以文件名后缀分组统计数量(分组统计)

ls -rtl |awk ‘{print $9}’|awk -F “.” ‘{print $2}’|sort|uniq -c

2、以文件名后缀统计总容量(分组求和)

ls -rtl |awk ‘{print $9,$5}’|awk -F “.” ‘{print $2}’|awk ‘{a[$1] += $2; }END{ for(i in a){ print i,a[i] } }’


©著作权归作者所有:来自51CTO博客作者Joker的原创作品,请联系作者获取转载授权,否则将追究法律责任 利用shell命令实现group by功能 https://blog.51cto.com/u_15104381/2621904