Bash output stream write to a file

后端 未结 4 1158
庸人自扰
庸人自扰 2020-12-11 08:22

so i am running this on bash:

# somedevice -getevent

What this command does is it just keeps running, and everytime my device sends a certa

4条回答
  •  时光说笑
    2020-12-11 08:25

    This is probably because your "somedevice -getevent" command's stdout is being block-buffered. According to this, stdout is by default line-buffered (i.e. what you want) if stdout is a terminal, and block-buffered otherwise.

    I'd have a look at the manual for your somedevice command to see if you can force the output to be unbuffered or line-buffered. If not, stdbuf -oL somedevice -getevent > my_record_file should do what you want.

提交回复
热议问题