on-the-fly output redirection, seeing the file redirection output while the program is still running

前端 未结 6 826
孤街浪徒
孤街浪徒 2021-02-08 01:36

If I use a command like this one:
./program >> a.txt &
, and the program is a long running one then I can only see the output once the program ended. That means I ha

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-08 02:01

    If you're trying to modify the behavior of an existing program try stdbuf (part of coreutils starting with version 7.5 apparently).

    This buffers stdout up to a line:

    stdbuf -oL command > output

    This disables stdout buffering altogether:

    stdbuf -o0 command > output

提交回复
热议问题