Code:
$ cat batman.awk
BEGIN { FS=","; ca=0; cb=0; d=""; t=""; }
{
if(($1 != d) || ($2 != t))
for(n=0; n<4-1; n++) a[n]="";
else for(n=0; n<4-1; n++) a[n]=a[n+1];
a[3]=sprintf("%s,%s",$3,$4);
if( (a[0] == "1,1")&&(a[1]=="0,1") &&
(a[2]=="1,0")&&(a[3]=="0,0") )
{
printf("Event A\n");
ca++;
}
if( (a[0]=="0,1")&&(a[1]=="1,1") &&
(a[2]=="0,0")&&(a[3]=="1,0") )
{
printf("Event B\n");
cb++;
}
d=$1; t=$2;
}
END {
printf("A\t%d\n", ca);
printf("B\t%d\n", cb);
}
$ cat batmon.dat
20/01/2011,10:10,1,1
20/01/2011,10:10,0,1
20/01/2011,10:10,1,0
20/01/2011,10:10,0,0
21/01/2011,10:15,0,1
21/01/2011,10:15,1,1
21/01/2011,10:15,0,0
21/01/2011,10:15,1,0
$ awk -f batman.awk < batmon.dat
Event A
Event B
A 1
B 1
$