3

ls对文件进行排序

 3 years ago
source link: https://www.lujun9972.win/blog/2018/11/19/ls%E5%AF%B9%E6%96%87%E4%BB%B6%E8%BF%9B%E8%A1%8C%E6%8E%92%E5%BA%8F/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ls对文件进行排序

ls 提供了大量的选项来根据不同条件对文件进行排序。这里只是做一个案例收集,方便查询

按名称从小到大排序

ls 本身默认输出就是按文件名称进行排序

ls

按文件大小从大到小排序

ls -S 

按文件修改时间从新到旧排序

ls -t

按文件最后访问时间从新到旧排序

ls -ut

按文件创建时间从新到旧排序

ls -Ut

按文件扩展名从小到大排序

ls -X

ls 命令添加选项 -r 即可按原顺序进行逆排序

比如按文件大小从小到大排序可以执行

ls -Sr

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK