shell 单引号内解析变量
1 2 3 4 5 6
| #!/bin/bash test2="java/haoqipei" test1="jjjjjjjjjj/bbbbb"
echo '{"kind":"deployments","namespace":"default","name":"qqipei","images":{"$test1":"$test1:$test2"}}' echo '{"kind":"deployments","namespace":"default","name":"qqipei","images":{"'$test1'":"'$test1:$test2'"}}'
|
执行结果如下
1 2 3
| {"kind":"deployments","namespace":"default","name":"qqipei","images":{"$test1":"$test1:$test2"}} {"kind":"deployments","namespace":"default","name":"qqipei","images":{"jjjjjjjjjj/bbbbb":"jjjjjjjjjj/bbbbb:java/haoqipei"}}
|
外层单引号起到变量引用得作用