linux系统中如何将当前目录下的文件从大到小排序和从小到大排序

1、创建5个测试数据文件

[root@centos7 test]# dd if=/dev/zero bs=1M count=100 of=a.txt
[root@centos7 test]# dd if=/dev/zero bs=1M count=10 of=b.txt
[root@centos7 test]# dd if=/dev/zero bs=1M count=1 of=c.txt
[root@centos7 test]# dd if=/dev/zero bs=1M count=150 of=d.txt
[root@centos7 test]# dd if=/dev/zero bs=1M count=50 of=e.txt

 

 

2、将当前目录下的文件从大到小排序

[root@centos7 test]# ls -S | xargs du -sh

 

 

3、将当前目录下的文件从小到大排序

[root@centos7 test]# ls -S | xargs du -sh |tac

 

posted @ 2021-06-24 23:26  小鲨鱼2018  阅读(1564)  评论(0编辑  收藏  举报