【发布时间】:2021-10-24 09:56:21
【问题描述】:
我正在尝试将第一个命令的输出通过管道传递到第二个命令末尾的引号中。
kubectl --context foo -n foo get secret postgres.foo-db.credentials -o jsonpath={.data.password}
kubectl --context foo -n foo patch secret postgres.foo-db.credentials -p '{"data":{"password":" Output from command 1 "}}'
我已经尝试过这个:piping output into middle of bash command,但是这个命令出现以下错误:
kubectl --context foo -n foo patch secret postgres.foo-db.credentials -p '{"data":{"`password":"kubectl --context foo -n foo get secret postgres.foo-db.credentials -o jsonpath={.data.password}`"}}'
The request is invalid: patch: Invalid value: "map[data:map[`password:kubectl --context foo -n foo get secret postgres.foo-db.credentials -o jsonpath={.data.password}`]]": error decoding from json: illegal base64 data at input byte 7
【问题讨论】:
-
管道在这里不行。你需要command substitution,因为你的命令的一部分应该被另一个命令的标准输出代替。
-
@WytrzymałyWiktor 是的:)
标签: json shell command kubectl