小编Zam*_*ezi的帖子

从文件中获取标准输入但仍然显示在终端中

我有一个程序需要我在程序运行时输入数据。想象一下它是这样的:

$ ./program
Hi there. What's your name? Zambezi
What is your quest? To make a program which runs nicely
What is your favourite color? Red
...
Run Code Online (Sandbox Code Playgroud)

现在,我有许多测试输入来运行我的程序。它们都包含以下内容:

Arthur, King of the Britons
To seek the Holy Grail
...
Run Code Online (Sandbox Code Playgroud)

然而,我的一些测试脚本失败了,不幸的是我很难准确地破译它们失败的地方,因为我的终端看起来像这样:

$ ./program < arthur.txt
Hi there. What's your name?What is your quest?What is your favourite color?...
Run Code Online (Sandbox Code Playgroud)

有没有办法我仍然可以stdin通过文件提供输入,但仍然让终端看起来好像我已经输入了所有内容?

如果重要的话,Linux Mint 16 是我的操作系统。

linux terminal bash

9
推荐指数
2
解决办法
1138
查看次数

标签 统计

bash ×1

linux ×1

terminal ×1