将交互式命令的输出重定向到文件和终端
我有一个需要用户输入的程序,我使用 tee
将其保存到文件中:
tee program.in | program
我还必须在另一个文件中捕获 stdout 和 stderr。问题
tee program.in | program > program.out 2>&1
是用户输入将基于程序之前输出的内容,因此用户必须在终端中查看程序输出。
关于如何实现这一目标有什么想法吗?
I have a program that requires user input, which I save to a file by using tee
:
tee program.in | program
I also have to capture stdout and stderr in another file. This does the trick
tee program.in | program > program.out 2>&1
The problem is that the user input is going to be based on what the program outputted before, so the user has to see the programs output in the terminal.
Any idea on how to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一种更惯用的
tee
:-?,即我希望这会有所帮助。
PS,由于您似乎是新用户,如果您得到的答案对您有帮助,请记住将其标记为已接受,和/或给它 +(或 -)作为有用的答案。
Another, more idiomatic
tee
:-?, i.e.I hope this helps.
P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.