Linux 如何查看上次创建的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7009240/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view last created file?
提问by
I have uploaded a file to a Linux computer. I do not know its name. So how to view files through their last created date attribute ?
我已将文件上传到 Linux 计算机。我不知道它的名字。那么如何通过上次创建的日期属性查看文件呢?
采纳答案by Uphill_ What '1
ls -lat
will show a list of all files sorted by date. When listing with the -l flag using the -t flag sorts by date. If you only need the filename (for a script maybe) then try something like:
将显示按日期排序的所有文件的列表。当使用 -t 标志与 -l 标志一起列出时,按日期排序。如果您只需要文件名(可能是脚本),请尝试以下操作:
ls -lat | head -2 | tail -1 | awk '{print }'
This will list all files as before, get the first 2 rows (the first one will be something like 'total 260'), the get the last one (the one which shows the details of the file) and then get the 9th column which contains the filename.
这将像以前一样列出所有文件,获取前 2 行(第一行类似于“总计 260”),获取最后一行(显示文件详细信息的行),然后获取第 9 列包含文件名。
回答by frarees
Use ls -lUt
or ls -lUtr
, as you wish. You can take a look at the ls
command documentation typing man ls
on a terminal.
使用ls -lUt
或ls -lUtr
,如您所愿。您可以查看在终端上ls
键入的命令文档man ls
。
回答by amrhassan
find / -ctime -5
Will print the files created in the last five minutes. Increase the period one minute at a time to find your file.
将打印最近五分钟内创建的文件。一次增加一分钟以查找您的文件。