linux - 文件更改时终端上的输出更改

linux - output changes on terminal when file changes

在打开的终端中,当进程向文件写入数据时,我如何才能看到添加到文件中的所有新内容?

我试过 cattee 的组合,但没有成功

将 tail 与 -f 结合使用

tail -f filename

摘自 tail 的手册页:

   -f, --follow[={name|descriptor}]
          output appended data as the file grows;

          an absent option argument means 'descriptor'

你不能使用cat,你应该使用tail -f <filename>less <filename>并按F以等待数据。

$ man less
   ...
   F      Scroll  forward, and keep trying to read when the end of file is reached.  Normally this
          command would be used when already at the end of the file.  It is a way to  monitor  the
          tail  of  a file which is growing while it is being viewed.  (The behavior is similar to
          the "tail -f" command.)
   ...