获取 Linux 目录中的最新文件 [英] Get most recent file in a directory on Linux
本文介绍了获取 Linux 目录中的最新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
寻找将返回目录中单个最新文件的命令.
Looking for a command that will return the single most recent file in a directory.
没有看到 ls
的限制参数...
Not seeing a limit parameter to ls
...
推荐答案
ls -Art | tail -n 1
不是很优雅,但很管用.
Not very elegant, but it works.
使用的标志:
-A
列出除 .
和 ..
-r
排序时倒序
-t
按时间排序,最新的在前
-t
sort by time, newest first
这篇关于获取 Linux 目录中的最新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文