linux向脚本传字符参数,linux – 如何使用特殊字符传递参数来调用...

改变线,

dbPassword=exam!ple#####

至,

dbPassword='exam!ple#####'

避免 ! (历史扩张)在bash中被特别对待

从QUOTING子节下的man bash,

When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character, usually !, must be quoted to prevent history expansion.

在历史扩张下更多

History expansions are introduced by

the appearance of the history expansion character, which is ! by

default. Only backslash (\) and single quotes can quote the history

expansion character.

此外,最好引用所有名称 – 值对以防止shell完成分词.

sh home/example.sh --context_param dbUserName="username" --context_param dbPassword='exam!ple#####' --context_param resultDate="2017-01-13"

关于分词,从手册页,

Word Splitting

The shell scans the results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double quotes for word splitting. The shell treats each character of IFS as a delimiter, and splits the results of the other expansions into words using these characters as field terminators

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值