shell sript的批处理并传递值

问题描述 投票:0回答:1

我有一个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 &

它终止了,没有问我任何事情。

linux shell batch-processing
1个回答
0
投票

我想您正在寻找一种将输入以批处理方式传递给脚本的方法。只需管道:

{ echo 1; echo 2; } | sh test.sh
© www.soinside.com 2019 - 2024. All rights reserved.