简体   繁体   English

使用 linux shell 显示目录中的最新文件

[英]display the most recent file in a directory using linux shell

I need to display the content of the recent file in a directory, for my example it's a log file that gets generated for each execution hence I need to display the newest one the command :我需要在目录中显示最近文件的内容,例如,它是为每次执行生成的日志文件,因此我需要显示最新的命令:

ls -Art | tail -n 1 

output the right name, meaning the most recent file in a directory, my goal is to output the content of this file by further piping How could we do this?输出正确的名称,意思是目录中最近的文件,我的目标是通过进一步管道输出这个文件的内容我们怎么能做到这一点?

cat `ls -Art | tail -n1`

或者,

ls -Art | tail -n 1 | xargs cat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM