我该如何在Bash中的AWS区域工作

发布于 2025-01-23 18:59:21 字数 267 浏览 2 评论 0原文

我正在使用此代码来获取我的AWS区域。我想在一段时间内处理它们。

awsRegionList=$(aws ec2 describe-regions | jq -r '.Regions[] | .RegionName')
while [I can't find the expression work with my variable]:
do
     echo " working on : (I want here the regionName)"
done    

I am using this code to get my AWS region. I want working on them in a while loop.

awsRegionList=$(aws ec2 describe-regions | jq -r '.Regions[] | .RegionName')
while [I can't find the expression work with my variable]:
do
     echo " working on : (I want here the regionName)"
done    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美男兮 2025-01-30 18:59:21

在bash中,您需要使用循环的在列表上迭代,而不是while循环:

awsRegionList=$(aws ec2 describe-regions | jq -r '.Regions[] | .RegionName')
for region in $awsRegionList
do
     echo " working on : ${region}"
done

In bash you need to use a for loop to iterate over a list, instead of a while loop:

awsRegionList=$(aws ec2 describe-regions | jq -r '.Regions[] | .RegionName')
for region in $awsRegionList
do
     echo " working on : ${region}"
done
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文