参考: 高级 bash 脚本编程指南
eval var1=$$var2
变量间接引用
贴个脚本:
server1=1.1.1.1 server2=1.1.1.2 server3=1.1.1.3 for s in server1 server2 server3 do eval server=$$s echo "$s=$server" done
参考: 高级 bash 脚本编程指南
eval var1=$$var2
贴个脚本:
server1=1.1.1.1 server2=1.1.1.2 server3=1.1.1.3 for s in server1 server2 server3 do eval server=$$s echo "$s=$server" done