linux - 由于参数中有空格,Bash 脚本因未知选项而失败

标签 linux bash amazon-web-services aws-lambda aws-cli

我正在尝试运行 aws create lambda 函数。内容如下 -

eval $(aws lambda create-function \
--function-name $FUNCTION_NAME \
--runtime $RUNTIME \
--role $ROLE \
--handler $HANDLER \
--region $REGION \
--zip-file $ZIP_FILE \
--profile $PROFILE \
--environment $env_variables)

所有变量都来自命令行。 env_variables 失败。这被构造为 -

env_variables="Variables={INPUT=${DAYS}}"

其中 DAYS 实际上是“20 天”

我怎样才能避免这个空间并成功传递我的命令。

最佳答案

该值需要用引号引起来,请尝试以下操作:

env_variables="Variables=\"{INPUT=${DAYS}}\""

关于linux - 由于参数中有空格,Bash 脚本因未知选项而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47111075/

相关文章:

linux - 在 linux 终端中使用 awk 命令忽略重复?

c - 在 Linux 上检测键盘按键按下和释放

bash - 不要在多个 bash 脚本中显示 pushd/popd 堆栈(安静的 pushd/popd)

python - django 和 AWS SES 服务设置 554 错误

amazon-web-services - 允许 AWS 用户创建自己的第一个访问 key

c++ - 在 Debian 8.3 ARM 上构建 Boost 单元测试框架

打开 screen 后的 Linux 脚本

linux - 在 Linux 中 ... 通向哪里?

bash - Bash 中的 Null 和空字符串比较

ruby-on-rails - 使用 Rails 和 Paperclip 的 s3 的简单 Amazon IAM 策略