0
运行脚本我有此脚本myprogram壳:标准输入使用输入重定向
#!/bin/bash
echo This is the first one ${1}.
echo This is the second one ${2}.
和输入文件test.txt
Hi
Hello
,我希望用输入重定向来运行脚本从test.txt输入,应输出
This is the first one Hi.
This is the second one Hello.
我正在尝试使用
./myprogram < test.txt
但它不工作。它唯一打印的是
This is the first one
This is the second one
任何人都可以帮我吗?
你的脚本没有曾经尝试从标准输入读取,所以您重定向标准输入什么没有任何效果。 –