1 Star 3 Fork 2

奶瓶OO/shell脚本

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
对比两台机器文件的差异.sh 764 Bytes
Copy Edit Raw Blame History
奶瓶OO authored 2020-02-09 19:10 . 我的shell代码
#!/bin/bash
#A机器,传输给B机器MD5值
#这两个脚本要分开写
dir=/data/web/
find $dir -type f > /tmp/dir.txt
[ -f /tmp/md5.txt ] && rm -f /tmp/md5.txt
exec < /tmp/dir.txt
while read line;do
md5sum $line >> /tmp/md5.txt
done
if [ -f /tmp/md5.txt ];then
scp -rp -P1314 /tmp/md5.txt 192.168.89.20:/tmp/ &>/dev/null
else
echo "/tmp/md5.txt不存在"
exit 1
fi
#B机器,判断B和A机器文件是否一样
#!/bin/bash
dir=/data/web/
if [ -f /tmp/md5.txt ];then
md5sum -c /tmp/md5.txt >> /tmp/md5sum.txt
if [ $? -ne 0 ];then
echo "192.168.89.30与192.168.89.20文件不相符,请查看/tmp/md5sum.txt文件"
else
echo "一切正常"
fi
else
echo "md5.txt文件传送异常"
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/NaiPingOO/shell_script.git
git@gitee.com:NaiPingOO/shell_script.git
NaiPingOO
shell_script
shell脚本
master

Search