1 [appop@VM-16-13-centos scripts]# cat riduizhang.sh
2 #!/bin/bash
3 #################################################
4 #yeahzxw
5 #20220620
6 #月对账文件生成,每月17号0点,并判断文件生成数量是否正确
7 #################################################
8
9 MONTH=`date +%F|cut -c1-4,6-7` #本月
10 MONTHONE=`date -d "1 month ago" +%Y%m` #上月
11 PROVINCE=`cat /scripts/province.txt` #省 100_1.txt
12 IFS=$'\n'
13 DIR=/rdata1/absfile/abs-file-cust/bak/$MONTH
14 cd $DIR
15 #创建文件
16 for PROV in $PROVINCE
17 do
18 touch BBOSS_Y_EC_${MONTHONE}_$PROV
19 touch BBOSS_Y_PO_${MONTHONE}_$PROV
20 touch BBOSS_Y_MO_${MONTHONE}_$PROV
21 chmod 777 $DIR/*${MONTHONE}_$PROV
22 done
23 #输出文件数量
24 NUMONE=`ls -l $DIR/BBOSS_Y_*_$MONTHONE_*_1.txt|wc -l`
25 #判断文件是否为93
26 if [ -f "*Y*${MONTHONE}_$PROV" ]
27 then echo '文件不存在'
28 else
29 if [ $NUMONE -eq 93 ]
30 then echo '文件存在且数量等于93'
31 else echo '文件存在但数量不等于93'
32 fi
33 fi
34
35 #===========================
36 [appop@VM-16-13-centos scripts]# cat province.txt
37 100_1.txt
38 200_1.txt
39 210_1.txt
40 220_1.txt
41 230_1.txt
42 240_1.txt
43 250_1.txt
44 270_1.txt
45 280_1.txt
46 290_1.txt
47 311_1.txt
48 351_1.txt
49 371_1.txt
50 431_1.txt
51 451_1.txt
52 471_1.txt
53 531_1.txt
54 551_1.txt
55 571_1.txt
56 591_1.txt
57 731_1.txt
58 771_1.txt
59 791_1.txt
60 851_1.txt
61 871_1.txt
62 891_1.txt
63 898_1.txt
64 931_1.txt
65 951_1.txt
66 971_1.txt
67 991_1.txt