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

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页