Piping an interactive session to a file

后端 未结 4 1840
萌比男神i
萌比男神i 2020-12-05 12:33

I have made a toy interactive console program that is basically an interpreter:

$ myprogram
> this is user input
this is program output

4条回答
  •  感动是毒
    2020-12-05 13:01

    As two processes can't read the same input two tees are needed, one which reads terminal input and writes to program standard input and file.log another which reads program standard output and writes into terminal output and file.log:

    tee -a file.log | program | tee -a file.log
    

提交回复
热议问题