【问题标题】:Do not print the error when running the AWS commmand运行 AWS 命令​​时不打印错误
【发布时间】:2019-10-29 12:31:09
【问题描述】:

我正在尝试通过运行命令删除安全组

for i in `aws ec2 describe-security-groups --filters Name=vpc-id,Values="${vpcid}" | grep sg- | sed -E 's/^.*(igw-[a-z0-9]+).*$/\1/'`; do aws ec2 delete-security-group --group-id $i; done

它将成功删除自定义安全组。但是,尝试删除默认安全组时会返回错误。我不希望在终端上返回错误,而是什么都不返回。

我尝试在delete-security-group 命令的末尾添加|| true,看起来像

for i in `aws ec2 describe-security-groups --filters Name=vpc-id,Values="${vpcid}" | grep sg- | sed -E 's/^.*(igw-[a-z0-9]+).*$/\1/'`; do aws ec2 delete-security-group --group-id $i || true; done

虽然错误仍然打印在终端上。任何帮助

【问题讨论】:

    标签: amazon-web-services amazon-ec2 aws-security-group


    【解决方案1】:

    使用command 2>/dev/null 重定向错误

    【讨论】:

      猜你喜欢
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 1970-01-01
      相关资源
      最近更新 更多