linux 中实现将指定目录中的所有文件从大到小或者从小到大排列

 

001、

复制代码
[root@pc1 test]# ls                  ## 测试文件
a.txt  b.txt  c.txt  d.txt  e.txt
[root@pc1 test]# ll -h
total 250M
-rw-r--r--. 1 root root 100M Oct 28 16:06 a.txt
-rw-r--r--. 1 root root  10M Oct 28 16:06 b.txt
-rw-r--r--. 1 root root  50M Oct 28 16:06 c.txt
-rw-r--r--. 1 root root  30M Oct 28 16:06 d.txt
-rw-r--r--. 1 root root  60M Oct 28 16:06 e.txt
[root@pc1 test]# ls -S | xargs -n 1 du -sh     ## 从大到小的顺序排列
100M    a.txt
60M     e.txt
50M     c.txt
30M     d.txt
10M     b.txt
[root@pc1 test]# ls -S | xargs -n 1 du -sh | tac     ## 从小到大的顺序排列
10M     b.txt
30M     d.txt
50M     c.txt
60M     e.txt
100M    a.txt
[root@pc1 test]# ls -S          ## 从大到小排列
a.txt  e.txt  c.txt  d.txt  b.txt
复制代码

 

posted @   小鲨鱼2018  阅读(168)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2021-10-28 R语言中在数据框中批量替换指定项
2021-10-28 R语言中统计数据框所有项中的并集
2020-10-28 linux系统中 raid10磁盘阵列损坏修复
2020-10-28 linux系统中部署raid10磁盘阵列
点击右上角即可分享
微信分享提示