最近公司上线生成管理员要求我提供一个脚本。用来比较我提交的文件清单和生产上传的tar文件产生的文件列表进行比较。脚本如下:
check_list.sh
#!/bin/sh
#用于上线的时候文件清单的比较
Num1=`cat 1.txt|wc -l`
Num2=`cat 2.txt|wc -l`
num=0
#用于上线的时候文件清单的比较
Num1=`cat 1.txt|wc -l`
Num2=`cat 2.txt|wc -l`
num=0
if [ $# != 2 ] ;then
echo "使用法:$0 参数1 参数2"
exit 1
else
if [ $Num1 -ne $Num2 ] ;then
echo "版本文件中的文件数目不一致"
else
echo "核对文件开始"
while read line
do
let num=num+1
echo "第$num行记录对比"
echo "$line"
sed -n "$num"p $2
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "\n"
echo "请输入任意键继续下一条的对比"
(
while read name1</dev/tty
do
if [ $name1 != "y" ] ;then
echo "比较结束"
exit 1
else
echo "下一行比较开始"
exit 0
fi
done
)
value=`echo $?`
if [ $value = 1 ];then
exit 1
fi
done<$1
fi
fi
echo "使用法:$0 参数1 参数2"
exit 1
else
if [ $Num1 -ne $Num2 ] ;then
echo "版本文件中的文件数目不一致"
else
echo "核对文件开始"
while read line
do
let num=num+1
echo "第$num行记录对比"
echo "$line"
sed -n "$num"p $2
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "\n"
echo "请输入任意键继续下一条的对比"
(
while read name1</dev/tty
do
if [ $name1 != "y" ] ;then
echo "比较结束"
exit 1
else
echo "下一行比较开始"
exit 0
fi
done
)
value=`echo $?`
if [ $value = 1 ];then
exit 1
fi
done<$1
fi
fi
转载于:https://blog.51cto.com/2922055/1132093