bash 下 hash array的支持
2016-04-08 15:00
281 查看
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/
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/
相关文章推荐
- 如何来进行一次bugbash
- shell文件/路径处理
- 是时候放弃putty了,推荐个putty的替代品:Xshell,Bitvise SSH Client
- 编写一个简易shell命令行
- Win10 14316 bash
- powershell中的两只爬虫
- 使用 Shell 脚本自动化 Linux 系统维护任务
- shell中如何进行数学运算
- Linux远程管理器xshell和xftp使用教程
- shell 脚本 找包含 某字符的 文件 的文件名
- Shell后台执行指令nohup
- Linux Shell的 & 、&& 、 ||
- shell后台执行指令&
- shell后台执行指令At
- shell后台执行指令cron和crontab
- shell中的字符串操作
- shell中if做比较
- Shell脚本[运算表达式,条件控制语句]
- shell中shift和eval的用法
- Shell for&while 循环详细总结