使用aws cli命令的输出作为另一个命令的输入

huangapple go评论50阅读模式
英文:

Using output of an aws cli command as an input for another command

问题

我一直在尝试使用list-backup-plans的输出作为get-backup-plan --backup-plan-id的输入。我尝试了这个命令,但似乎不适用于多个备份计划ID。有人能告诉我正确的命令可以用什么吗?

aws backup list-backup-plans --query BackupPlansList[*].BackupPlanId | xargs -I {} aws backup get-backup-plan --backup-plan-id {}
英文:

I have been trying to use output of the list-backup-plans to use as input for get-backup-plan --backup-plan-id. I tried this command but it seems inappropriate for multiple backup plan ids. Could someone address me what correct command can be used?

aws backup list-backup-plans --query BackupPlansList[*].BackupPlanId | xargs -I {} aws backup get-backup-plan --backup-plan-id {}

答案1

得分: 1

请确保指定 --output 选项,并将制表符替换为换行符:

aws backup list-backup-plans --query 'BackupPlansList[*].BackupPlanId' --output text | tr "\t" "\n" | xargs -I {} aws backup get-backup-plan --backup-plan-id {}
英文:

Make sure to specify the --output option, and replace tabs with newlines:

aws backup list-backup-plans --query 'BackupPlansList[*].BackupPlanId' --output text | tr "\t" "\n" | xargs -I {} aws backup get-backup-plan --backup-plan-id {}

huangapple
  • 本文由 发表于 2023年6月8日 22:38:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76432980.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定