#!/bin/bash function rr(){ rsync -aSH --delete -e 'ssh' /usr/local/hadoop/etc/hadoop $1:/usr/local/hadoop/etc/ rsync -a --delete -e 'ssh' /etc/hosts $1:/etc/hosts } if (( $# == 0 ));then echo "用法:$0 host1 host2 host3 ...." else for ((i=1;i<=$#;i++)); do rr ${!i} ############## [root@room9pc01 ~]# A=123 [root@room9pc01 ~]# B=A [root@room9pc01 ~]# echo $B A [root@room9pc01 ~]# echo $!B B [root@room9pc01 ~]# echo ${!B} 123