【めも】binlog shell

#!/bin/bash

grep -v "^SET\|latin1" ${1} \
        | grep -B 1 "^BEGIN\|^COMMIT" \
        | grep "^#[0-9]*" \
        | awk ' BEGIN{bt_cnt = 0; ct_cnt =0}
                {
                gsub("#","",$1);
                Y="20" substr($1,1,2);
                gsub(":"," ",$2);
                M=substr($1,3,2);
                D=substr($1,5,2);
                if (NR % 2 == 1){
                    bt =  mktime(Y" "M" "D" "$2);
                    ++bt_cnt;
                }else if (NR % 2 == 0) {
                    ct =  mktime(Y" "M" "D" "$2);
                    ++ct_cnt;
                }
                if (bt_cnt == ct_cnt) {
                     if ( ct - bt > 1){
                             print $0;
                     }
                }
        }'