【问题标题】:display the most recent file in a directory using linux shell使用 linux shell 显示目录中的最新文件
【发布时间】:2017-09-25 12:20:29
【问题描述】:

我需要在目录中显示最近文件的内容,对于我的示例,它是为每次执行生成的日志文件,因此我需要显示最新的 命令:

ls -Art | tail -n 1 

输出正确的名称,意思是目录中最近的文件,我的目标是通过进一步管道输出这个文件的内容 我们怎么能这样做?

【问题讨论】:

    标签: linux shell ubuntu command-line


    【解决方案1】:
    cat `ls -Art | tail -n1`
    

    或者,

    ls -Art | tail -n 1 | xargs cat
    

    【讨论】:

      猜你喜欢
      • 2011-12-08
      • 1970-01-01
      • 2014-04-23
      • 2013-12-08
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多