写了两天脚本,不懂什么就网上搜,感觉零零碎碎学了不少东西,先把代码贴上来,明天周末有空一条一条找知识点吧
#!/bin/bash
# by wuboxiao
rm -rf checkConfig.diff checkConfig.same checkConfig.error checkConfig.result
files=`find $1/src/main/resources/performance -name "*.properties"`
for i in $files;do
diff $i ${i/performance/stable} 1>>checkConfig.result 2>>checkConfig.result
if [ $? -eq 0 ]; then
echo $i,${i/performance/stable} 1>>checkConfig.same
else
diff $i ${i/performance/stable} -y 1>>checkConfig.result 2>>checkConfig.result
if [ $? -eq 1 ];then
echo $i,${i/performance/stable} 1>>checkConfig.diff
diff $i ${i/performance/stable} -y --suppress-common-lines 1>>checkConfig.diff
elif [ $? -eq 2 ];then
echo "结果为2"
else diff $i ${i/performance/stable} -y 2>>checkConfig.error
fi
echo -e "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
fi
done
echo -e "\e[1;31m配置文件缺失检查结果:\e[0m"
if [ ! -f checkConfig.error ];then
echo "无配置文件缺失"
else cat checkConfig.error
fi
echo -e "\e[1;31m配置文件不同检查结果:\e[0m"
if [ ! -f checkConfig.diff ];then
echo "无不同的配置文件"
else cat checkConfig.diff
fi
if [ $# -eq 2 ];then
echo -e "\e[1;31m配置文件相同检查结果:\e[0m"
if [ ! -f checkConfig.same ];then
echo "无相同的配置文件"
else cat checkConfig.same
fi
fi