我有一个shell脚本(test.sh),其中包含一些在Linux中执行期间要传递的参数。例如,
# sh test.sh #My script
Choose model name
0:ESM 1:WED 2:PWD
1 #I need to choose one from the above
Choose time period
0:2050 1:2080 2:2100
2 #I need to choose one from the above
Downloading WED data for 2100 #download started
....
我正在寻找用于执行上述示例的test.sh的命令。我尝试过
sh test.sh > & out &
它终止了,没有问我任何事情。
我想您正在寻找一种将输入以批处理方式传递给脚本的方法。只需管道:
{ echo 1; echo 2; } | sh test.sh