Bash 如何使用嵌套的AWS CLI命令语法?
下面是在bash上运行的两个不同的AWS CLI命令:Bash 如何使用嵌套的AWS CLI命令语法?,bash,aws-cli,Bash,Aws Cli,下面是在bash上运行的两个不同的AWS CLI命令: IMAGES_TO_DELETE=$( aws ecr list-images --region $ECR_REGION --repository-name $ECR_REPO --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json ) aws ecr batch-delete-image --region $ECR_REGION --repository-nam
IMAGES_TO_DELETE=$( aws ecr list-images --region $ECR_REGION --repository-name $ECR_REPO --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output json )
aws ecr batch-delete-image --region $ECR_REGION --repository-name $ECR_REPO --image-ids "$IMAGES_TO_DELETE" || true
其中第一个命令在图像中存储JSON格式[{“imageDigest”:“sha256:…”},{“imageDigest”:“sha256:…”},…]
在可以运行单个嵌套命令的场景中:
aws ecr batch-delete-image --region us-west-2 --repository-name "somedockerimage" --image-ids “$(aws ecr list-images --region us-west-2 --repository-name "somedockerimage" --filter "tagStatus=UNTAGGED" --query 'imageIds[*]' --output text)” || true
给出错误:
Error parsing parameter '--image-ids': Expected: '=', received: '“' for input:
“sha256:cccccccccc983f4185f48fb968634dae8c4276ee1a7ffffffffffffff
^
Error parsing parameter '--image-ids': Expected: '=', received: '“' for input:
“[
^
给出错误:
Error parsing parameter '--image-ids': Expected: '=', received: '“' for input:
“sha256:cccccccccc983f4185f48fb968634dae8c4276ee1a7ffffffffffffff
^
Error parsing parameter '--image-ids': Expected: '=', received: '“' for input:
“[
^
在第二个命令中,替换“$IMAGES\u to_DELETE”
的嵌套语法是什么?将智能引号“…”
更改为直引号“…
”