Bash
對“人類可讀”文件大小進行排序
我們如何使用任何 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 ...
非常感謝
sort
有一個選擇--human-numeric-sort
,並--sort=human-numeric
做到這一點。