## Linux案列
1.用ls来查找最近更新过的文件。
在工作中,我们经常需要查看一个有很多文件的目录,找出最近更新过但不知道具体文件名的文件,这时就可以用ls-lrt或ls-rt这个组合命令。
[root@oldboy test]# touch /etc/test.txt #<==创建一个新文件,假设不知道名字,你如何快速找到它?
[root@oldboy test]# ls -lrt /etc/ #<==-t是按时间排序,-r是倒序,即按时间倒序排序。
#...省略N多文件行...
-rw-r--r-- 1 root root 301 May 22 10:17 mtab
drwxr-xr-x 9 root root 4096 May 22 10:22 sysconfig
-rw-r--r-- 1 root root 0 May 22 20:55 test.txt
#<==不用翻屏回查,最后一屏的最后一行就是我们需要查找的文件。如果直接定位文件还可以用如下命令。
[root@oldboy test]# ls -lrt /etc|tail -1 #<==tail命令后面会讲。
-rw-r--r-- 1 root root 0 May 22 20:55 test.txt