bash 判断两个文件相等的代码

#!/bin/bash
#定义参数
username="xxx"
passwd="xxxxxxxx"
dbname="xxx"

#判断入参为空
if [ ! -d $# ];then
echo "please input"
exit 1
fi

#判断入参不为1或2
if [ $# -ne 1 || $# -ne 2 ];then
echo "input false"
exit 1
fi

#执行Shoppingmall report脚本
./home/QA_Deploy/dp/DataExchange/program/quartz/Shopping.sh $1 $2

#获取当期啊日期
time=$(date "+%Y%m%d")
#读取Shoppingmall report第二列兵排序保存到Shopping_mall_winning_report_$time.txt
cat /home/QA_Deploy/dp/DataExchange/WORK/C4_SMW/Out/Shopping_mall_winning_report_$time.csv|cut -d ',' -f 2|sort > Shopping_mall_winning_report_$time.txt
#判断是否成功
if [ -d "Shopping_mall_winning_report_$time.txt"];then
echo "Shopping_mall_winning_report_$time.txt"
else
echo "execute failed"
fi


#连接数据库执行SQL导出预期报表数据
su - oracle <<EOF
ppppppppppppppppppppppppppppppppppppppppppp;
exit;
EOF
function get_test_data()
{
sqlplus $username/$passwd@$dbname <<!
set linesize 5000 num 14;
set numw 20;
SELECT 'f', 
             INV_CODE        as inv_code,
             XUA_CARRIER_NO  as carrier_no,
           XUA_FULL_CNNAME as full_cnname,
           XUA_EMAIL       as email,
           XUA_MOBILE      as mobile,
             IVP_CODE        as inv_win_code,
             MMB_ID,
             mmb_cst_id,
             INV_MMB_ID,
             XMB_MMB_ID,
             UAC_UGR_ID,
             XMB_BIND_UGR_ID,
             XUA_UAC_ID,
             UAC_ID,
             IVP_ID,
             INV_PRIZE_TYPE_ID,
             INV_ID,
             INV_CARRIERID
         
           FROM BINVOICE LEFT JOIN BMEMBERSHIP ON MMB_ID = INV_MMB_ID 
           LEFT JOIN XMEMBERSHIP       ON XMB_MMB_ID = MMB_ID 
           LEFT JOIN BUNIVERSALACCOUNT ON UAC_UGR_ID = XMB_BIND_UGR_ID 
           JOIN XUNIVERSALACCOUNT ON XUA_UAC_ID = UAC_ID 
           LEFT JOIN RINVOICEPRIZE     ON IVP_ID     = INV_PRIZE_TYPE_ID 
           WHERE  XUA_CARRIER_NO = INV_CARRIERID
           ORDER BY INV_DATE DESC,INV_ID DESC;
exit;
!
}
get_test_data|grep ^f|awk '{print$3}'|sort > /home/QA_Deploy/fang/Shopping_mall_winning_oracle_$time.txt

exit;

#判断是否导出成功
if [ -d "Shopping_mall_winning_oracle_$time.txt"];then
echo "Shopping_mall_winning_oracle_$time.csv"
else
echo "export failed"
fi

#将生成的Shoppingmall report与导出的预期report数据进行对比
if [ -d "Shopping_mall_winning_oracle_$time.txt" && -d "Shopping_mall_winning_report_$time.txt" ];then
echo "diff result-------------------------------------"
diff Shopping_mall_winning_oracle_$time.txt Shopping_mall_winning_report_$time.txt > date_diff.log
tail -n 100 date_diff.log
fi


 

  

posted @ 2018-05-23 15:13  巴黎爱工作  阅读(467)  评论(0编辑  收藏  举报