linux 中 sort -h选项

发布时间 2023-07-25 17:04:25作者: 小鲨鱼2018

 

-h:使用易读性数字,比如 K, G单位。

 

001、

[root@PC1 test02]# ls
a.txt
[root@PC1 test02]# cat a.txt        ## 测试数据
2G
3K
4K
1G
[root@PC1 test02]# sort a.txt
1G
2G
3K
4K
[root@PC1 test02]# sort -n a.txt
1G
2G
3K
4K
[root@PC1 test02]# sort -h a.txt     ## 按照易读性数字排序
3K
4K
1G
2G

 。