您的位置:首页 > 其它

比较多台机器配置文件是否相同 remote_diff.sh

2012-07-31 14:36 323 查看
#!/bin/sh

if [ $# -ne 2 ] ; then
    echo 'error args';
    exit ;
fi
file=$1;
machine=$2;

rm -rf ~/.tmp/*;
yinst ssh -c "scp '$1' hostname:~/.tmp/\`hostname -s\` " -h $machine 2>/dev/null;

first_file="";
for i in ~/.tmp/*; do
    if [ "$first_file"  == "" ]; then
        first_file=$i;
    else
        echo "diff $i $first_file";
        diff "$i" "$first_file";
    fi
done


2. 用法:

(1). remote_diff.sh /home/....../test.conf "abc[1-4].cm7 -h mach.cm7"

把远程所有机器的配置文件copy 到 本地 ~/.tmp目录中;然后所有的配置文件与第一个配置文件进行diff;打印出不同的信息

(2). 批量处理命令:yinst
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: