#!/bin/bash
file1="/opt/test1"
file2="/opt/test2"
# 函数内的exit,可以退出整个sh脚本,不再执行后续的步骤
compareMD5() {
file1="$1"
file2="$2"
md5_1=$(md5sum "$file1" | awk '{print $1}')
md5_2=$(md5sum "$file2" | awk '{print $1}')
if [ "$md5_1" = "$md5_2" ]; then
echo "MD5 values are the same"
else
echo "MD5 values are different"
exit 1
fi
}
compareMD5 $file1 $file2
echo "------ end ------"
Shell - 对比两个文件MD5值函数封装
猜你喜欢
转载自blog.csdn.net/xuezhangjun0121/article/details/135288566
今日推荐
周排行