Linux 通过传递值批量运行shell sript

Linux 通过传递值批量运行shell sript,linux,shell,batch-processing,Linux,Shell,Batch Processing,我有一个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

我有一个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
或者,我有时使用printf%s\n执行此操作,它不需要为多行输入执行{}大括号

printf "%s\n" 1 2 "another arg" "etc.." | sh test.sh

在命令行中给出参数,并使用变量$1、$2等来使用它们

./test.sh arg1 arg2 > out

>&out&您认为这意味着什么?我想将详细信息保存在out文件中,以便以后检查任何错误。