简体   繁体   中英

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

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    

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM