https://blog.51cto.com/wujianwei/2117249

[root@git-server ~]# cat /tmp/info1.txt 
DELIMITER 
#at 4
#180516 23:15:16 server id 1  end_log_pos 120 CRC32 0x183f4334  Start: binlog v 4, server v 5.6.36-log created 180516 23:15:16 at startup
#Warning: this binlog is either in use or was not closed properly.
ROLLBACK
#at 120
#180516 23:15:39 server id 1  end_log_pos 194 CRC32 0x0a6c78ee  Query   thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1526483739
SET @@session.pseudo_thread_id=1
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1
SET @@session.sql_mode=1075838976
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1

SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33
SET @@session.lc_time_names=0
SET @@session.collation_database=DEFAULT
BEGIN

#at 194
#180516 23:15:39 server id 1  end_log_pos 254 CRC32 0x10198556  Table_map: `zixun3`.`zx_scores` mapped to number 70
#at 254
#180516 23:15:39 server id 1  end_log_pos 517 CRC32 0x59f30b1c  Delete_rows: table id 70 flags: STMT_END_F
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=15 
###   @2='大将' 
###   @3=12 
###   @4=29000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=12 
###   @2='上将' 
###   @3=11 
###   @4=24000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=11 
###   @2='中将' 
###   @3=10 
###   @4=19000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=10 
###   @2='少将' 
###   @3=9 
###   @4=14000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=9 
###   @2='上校' 
###   @3=8 
###   @4=9000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=8 
###   @2='中校' 
###   @3=7 
###   @4=6000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=7 
###   @2='少校' 
###   @3=6 
###   @4=5000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=6 
###   @2='上尉' 
###   @3=5 
###   @4=4000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=5 
###   @2='中尉' 
###   @3=4 
###   @4=3000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=4 
###   @2='少尉' 
###   @3=3 
###   @4=2000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=3 
###   @2='班长' 
###   @3=2 
###   @4=1000 
###   @5=1 
### DELETE FROM `zixun3`.`zx_scores`
### WHERE
###   @1=2 
###   @2='列兵' 
###   @3=1 
###   @4=0 
###  @5=1 
#at 517
#180516 23:15:39 server id 1  end_log_pos 592 CRC32 0x36661206  Query   thread_id=1 exec_time=0 error_code=0
SET TIMESTAMP=1526483739
COMMIT

DELIMITER ;
#End of log file
ROLLBACK
#!/bin/bash

#bl表列数(表字段) #语句yj
bl=5
yj=DELETE
zs1=`awk '/#180516/,/#180517/ {print $0}' /tmp/info1.txt|awk '"/$yj/",/# at/ {print $0}'|grep ^###|grep "@"|cut -d"=" -f2`
zs2=`echo $zs1|awk '{print NF}'`
zt=`echo "$zs2/$bl"|bc`
hs=0
##databa指数据库  ###tab指表 ###a1--a5指的是此表一共有5个字段
databa=zixun3
tab=zx_scores
ztt=$(($zt+0))
ii=0

a1=1
a2=2
a3=3
a4=4
a5=5
  while [[ $ii -lt $ztt ]];do
l1=`echo $zs1|awk '{print $'"$a1"'}'`
l2=`echo $zs1|awk '{print $'"$a2"'}'`
l3=`echo $zs1|awk '{print $'"$a3"'}'`
l4=`echo $zs1|awk '{print $'"$a4"'}'`
l5=`echo $zs1|awk '{print $'"$a5"'}'`
echo "use $databa;insert into $tab values($l1,$l2,$l3,$l4,$l5)" >>/tmp/hf

a1=$(($a1+$bl))
a2=$(($a2+$bl))
a3=$(($a3+$bl))
a4=$(($a4+$bl))
a5=$(($a5+$bl))
ii=$(($ii+1));
  done