bash 下 hash array的支持

来源:互联网 发布:java deletecharat 编辑:程序博客网 时间:2024/04/28 10:23

declare -A region_URLs
region_URLs[beijing]="https://1.com"
region_URLs[shanghai]="https://2.com"
region_URLs[Sydney]="https://3.com"


for site in "${!region_URLs[@]}"; do
        echo $site -- ${region_URLs[$site]}
done


root@219:~# bash test.sh
shanghai -- https://2.com
Sydney -- https://3.com
beijing -- https://1.com



References: http://www.artificialworlds.net/blog/2012/10/17/bash-associative-array-examples/

0 0
原创粉丝点击