- #!/bin/sh
- mday=$(date +%Y%m%d -d "1 day ago")
- fday=$(date +%m%d -d "1 day ago") #filename
- filedir=/home/fanhy
- #echo $mday
- #cur_dir=$(pwd)
- #arg=$1
- #echo $arg
- #echo $mday
- #grep ' unsign' $filedir
- #cat $filedir/*.txt|grep 'unsign' > $filedir/test.log
- grep ' unsign' $filedir/*_$fday.txt | awk -F "total): " '{print $2}'| awk '{a[$1]+=$2}END{for(i in a) if(i>0 && a[i]>0) print "INSERT INTO match_signret_stat(`ma
- tch_id`,`day`,`state`,`num`)VALUES(" i,"," m,"," 2,"," a[i] ");"}' RS=" " FS=":" m=$mday > $filedir/$mday.unsign.sql
- grep ' sign' $filedir/*_$fday.txt | awk -F "total): " '{print $2}'| awk '{a[$1]+=$2}END{for(i in a) if(i>0 && a[i]>0) print "INSERT INTO match_signret_stat(`matc
- h_id`,`day`,`state`,`num`)VALUES(" i,"," m,"," 1,"," a[i] ");"}' RS=" " FS=":" m=$mday > $filedir/$mday.sign.sql
- ##mysql insert
- /usr/bin/mysql -uroot jjstat < $filedir/$mday.unsign.sql;
- /usr/bin/mysql -uroot jjstat < $filedir/$mday.sign.sql;
- #该片段来自于http://www.codesnippet.cn/detail/160520133409.html
来源: http://www.codesnippet.cn/detail/160520133409.html