Piping an interactive session to a file

后端 未结 4 1834
萌比男神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:05

    The simpler form could be

    tee >(myprogram) | tee -a file.log
    

    If you want to prevent input being shown again to the screen:

    tee -a file.log | myprogram | tee -a file.log
    

提交回复
热议问题