我们如何使用任何 Linux 核心实用程序(脚本)对 du 输出的数值进行排序,例如:
136K foo.bar/feed
140K foo.bar/buy-electronic-components
32K foo.bar/cdn-cgi
88K foo.bar/what-is-ground
344K foo.bar/ldr-circuit-diagram
64K foo.bar/what-is-an-led
100K foo.bar/types-of-resistors
516K foo.bar/wp-includes
60K foo.bar/author
56K foo.bar/diy-pcb
112K foo.bar/how-to-learn-electronics
376K foo.bar/category
76K foo.bar/electronic-schematics
84K foo.bar/how-to-bar
88K foo.bar/bar-tools
20K foo.bar/comments
88K foo.bar/right-bar-temperature
48K foo.bar/contact
44K foo.bar/products
80K foo.bar/types-of-bar
3M foo.bar/
3M total
如果按降序排列为:
3M foo.bar/
3M total
516K foo.bar/wp-includes
376K foo.bar/category
344K foo.bar/ldr-circuit-diagram
140K foo.bar/buy-electronic-components
...
非常感谢
答案1
sort
有一个选择--human-numeric-sort
并且--sort=human-numeric
可以做到这一点。