#!/bin/bash
#必须先声明
declare -A dic0
declare -A dic1
declare -A dic2
declare -A dic3
dic0=([ip]="192.168.56.120" [m_pwd]="xxxxxx" [r_pwd]="xxxxxx")
dic1=([ip]="192.168.56.121" [m_pwd]="xxxxxx" [r_pwd]="xxxxxx")
dic2=([ip]="192.168.56.122" [m_pwd]="xxxxxx" [r_pwd]="xxxxxx")
dic3=([ip]="192.168.56.123" [m_pwd]="xxxxxx" [r_pwd]="xxxxxx")
ALL=(0 1 2 3)
for ip in ${ALL[@]}
do
eval echo '$'"{dic${ip}["ip"]}"
eval echo '$'"{dic${ip}["m_pwd"]}"
eval echo '$'"{dic${ip}["r_pwd"]}"
done