如何将Shell命令行参数映射到READ命令

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

我的程序接受了用户的2个参数

echo "Enter First code :"; read code_1
echo "Enter Second code :"; read code_2

我运行test.ksh并提示用户输入。

说用户输入1和2

Enter First code : 1
Enter Second code : 2

现在无需编辑test.ksh,我如何映射在命令行中传递的参数以读取Shell脚本中的语句?

test.ksh 1 2

Enter First code : 1
Enter Second code : 2
linux shell unix scripting ksh
1个回答
1
投票

您不;您可以将这些值写入脚本标准输入中。

printf '1\n2\n' | test.ksh
© www.soinside.com 2019 - 2024. All rights reserved.