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
分类:
linux shell
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!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磁盘阵列