【问题标题】:How to redirect console input to file bash如何将控制台输入重定向到文件bash
【发布时间】:2015-02-27 16:36:42
【问题描述】:

我有一个控制台应用程序,我希望它的输出出现在控制台上并存储在一个文件中。我一直在使用 tee 输出到控制台和文件,但我也希望将用户输入写入文件

现在写我一直在用

./a.out | tee -a output.txt

我看到了很多关于如何从文件重定向的建议,也看到了这个链接How to redirect console output to file and STILL get it in the console?

建议使用 2>$1,但这仍然无法让用户输入文件。

【问题讨论】:

  • ` nano some_file` :)
  • 您需要在程序本身中echo 用户输入才能将其放入文件中。

标签: bash redirect input console


【解决方案1】:

你可以试试script 命令。

例如script inout.txt ./a.out

【讨论】:

    猜你喜欢
    • 2013-12-07
    • 2023-03-19
    • 2011-02-22
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-14
    相关资源
    最近更新 更多