Shell脚本中的可选变量

时间:2020-06-22 13:50:49

标签: bash shell

我想在脚本中包含可选变量,因为我并不总是需要使用它们。

例如,在我的脚本中,我有:

hiveParams=""
if [ "$1" == hiveParams=* ]; ### if the first param starts with hiveParams=
then
echo "$hiveParams"
spark submit --conf spark.sql.hive.conf.list=\$hiveParams
fi

当我运行脚本时,我希望脚本使用“ TestHiveParams”并将其替换为$ hiveParams

sh test.sh hiveParams="TestHiveParams"

我该如何运行?

更新: 我添加了:

 set -o --

并运行作业:

sh test.sh --hiveParams="someParams"

我得到参数的数量是0。

我应该如何定义它,以便它能够识别它?

0 个答案:

没有答案