Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vieyahn2017 opened this issue May 15, 2023 · 2 comments
Open

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

vieyahn2017 opened this issue May 15, 2023 · 2 comments

Comments

@vieyahn2017
Copy link
Owner

shell命令实现group by功能

@vieyahn2017
Copy link
Owner Author

@vieyahn2017
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant