【问题标题】:tail -f starting with the entire filetail -f 从整个文件开始
【发布时间】:2017-05-06 01:02:00
【问题描述】:

我想关注一个文件,但tail -f 总是从最后 10 行开始。有没有办法输出整个文件然后跟随?

我的目标是查找日志中所有出现的字符串,例如tail -f streaming_log | grep "string"。但也包括所有前面的行。

我知道我可以做到tail -f -n 10000 file,但我不想先数行数。

【问题讨论】:

    标签: tail


    【解决方案1】:

    -n +<line> 允许您指定 开始 行(基于1):

    tail -f -n +1 file  # output entire file, then wait for new content
    

    【讨论】:

      猜你喜欢
      • 2011-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-12
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多