Linux: 使用bash命令ls按时间排序

在终端中,使用ls默认是按文件名排序的,常常会找不到最近修改过的文件:

zhang@debian:/$ ls -l
total 76
drwxr-xr-x  2 root root  4096 Jun 15 20:44 bin
drwxr-xr-x  3 root root  4096 Jun 15 20:19 boot
drwxr-xr-x 17 root root  3100 Jun 21 09:58 dev
drwxr-xr-x 99 root root  4096 Jun 21 09:58 etc
drwxr-xr-x  3 root root  4096 Jun 15 20:19 home
lrwxrwxrwx  1 root root    29 Jun 15 20:11 initrd.img -> boot/initrd.img-4.9.0-9-amd64
lrwxrwxrwx  1 root root    29 Jun 15 20:11 initrd.img.old -> boot/initrd.img-4.9.0-9-amd64
drwxr-xr-x 16 root root  4096 Jun 15 20:44 lib
drwxr-xr-x  2 root root  4096 Jun 15 20:11 lib64
drwx------  2 root root 16384 Jun 15 20:11 lost+found
drwxr-xr-x  3 root root  4096 Jun 15 20:11 media
drwxr-xr-x  2 root root  4096 Jun 15 20:11 mnt
drwxr-xr-x  2 root root  4096 Jun 15 20:11 opt
dr-xr-xr-x 98 root root     0 Jun 21 09:58 proc
drwx------  3 root root  4096 Jun 19 22:40 root
drwxr-xr-x 19 root root   580 Jun 21 10:02 run
drwxr-xr-x  2 root root  4096 Jun 15 20:44 sbin
drwxr-xr-x  2 root root  4096 Jun 15 20:11 srv
dr-xr-xr-x 13 root root     0 Jun 21 09:58 sys
drwxrwxrwt  9 root root  4096 Jun 21 10:02 tmp
drwxr-xr-x 10 root root  4096 Jun 15 20:11 usr
drwxr-xr-x 11 root root  4096 Jun 15 20:11 var
lrwxrwxrwx  1 root root    26 Jun 15 20:11 vmlinuz -> boot/vmlinuz-4.9.0-9-amd64
lrwxrwxrwx  1 root root    26 Jun 15 20:11 vmlinuz.old -> boot/vmlinuz-4.9.0-9-amd64

如果想要按照时间顺序,运行如下命令:

zhang@debian:/$ ls -lt
total 76
dr-xr-xr-x 13 root root     0 Jun 21 10:09 sys
drwxrwxrwt  9 root root  4096 Jun 21 10:02 tmp
drwxr-xr-x 19 root root   580 Jun 21 10:02 run
drwxr-xr-x 99 root root  4096 Jun 21 09:58 etc
drwxr-xr-x 17 root root  3100 Jun 21 09:58 dev
dr-xr-xr-x 98 root root     0 Jun 21 09:58 proc
drwx------  3 root root  4096 Jun 19 22:40 root
drwxr-xr-x  2 root root  4096 Jun 15 20:44 bin
drwxr-xr-x  2 root root  4096 Jun 15 20:44 sbin
drwxr-xr-x 16 root root  4096 Jun 15 20:44 lib
drwxr-xr-x  3 root root  4096 Jun 15 20:19 home
drwxr-xr-x  3 root root  4096 Jun 15 20:19 boot
lrwxrwxrwx  1 root root    29 Jun 15 20:11 initrd.img -> boot/initrd.img-4.9.0-9-amd64
lrwxrwxrwx  1 root root    26 Jun 15 20:11 vmlinuz -> boot/vmlinuz-4.9.0-9-amd64
lrwxrwxrwx  1 root root    29 Jun 15 20:11 initrd.img.old -> boot/initrd.img-4.9.0-9-amd64
lrwxrwxrwx  1 root root    26 Jun 15 20:11 vmlinuz.old -> boot/vmlinuz-4.9.0-9-amd64
drwxr-xr-x  2 root root  4096 Jun 15 20:11 lib64
drwxr-xr-x 10 root root  4096 Jun 15 20:11 usr
drwxr-xr-x 11 root root  4096 Jun 15 20:11 var
drwxr-xr-x  2 root root  4096 Jun 15 20:11 opt
drwxr-xr-x  2 root root  4096 Jun 15 20:11 srv
drwxr-xr-x  2 root root  4096 Jun 15 20:11 mnt
drwxr-xr-x  3 root root  4096 Jun 15 20:11 media
drwx------  2 root root 16384 Jun 15 20:11 lost+found

参与评论 您还未登录,请先 登录 后发表或查看评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页

打赏作者

淡竹云开

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值