簡體   English   中英

我如何在 Bash 的 while 列表中處理 aws 區域

[英]How can I work on aws regions in a while list in Bash

我正在使用此代碼獲取我的 AWS 區域。 我想在一個 while 循環中處理它們。

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    

在 bash 中,您需要使用for循環來遍歷列表,而不是while循環:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM