如何将管道输出重定向到显示而不是文件?

For*_*ail 1 linux command-line-interface

在 linux CLI 上:我有 3 天的运行扫描,我通过管道传输到文件(我知道,应该让它在内部写入文件)。

这让我想到了我的问题,说我有一个命令

long_process_here > output.txt

有没有办法在进程仍在运行显示或输出该信息?将内存中的内容通过管道传输到屏幕?

Der*_*rfK 8

有一个名为的程序tee将输入写入文件,因为它在屏幕上输出它:

long_process_here | tee output.txt
Run Code Online (Sandbox Code Playgroud)

现在您已经运行了程序,您可以使用tail“跟随”输出文件并在添加新行时输出它们:

tail -f output.txt
Run Code Online (Sandbox Code Playgroud)

  • @ForkrulAssail 这取决于你惊人的无休止的过程是什么。例如,如果那里有一个 grep,默认情况下 grep 一次缓冲一堆数据。 (2认同)