Eu montei um script Perl que, esperançosamente, faz o que você está procurando. Ele supõe que os dados que você forneceu em seu exemplo estão em um arquivo chamado temp
.
#!/usr/bin/perl
### ./timetract.pl
## 01/10/2000 09:00 01/11/2000 09:00 -9
## 01/11/2000 09:00 01/11/2000 21:30 -9
## 01/11/2000 22:30 01/12/2000 09:00 -9
## ...
## 01/17/2000 09:00 01/18/2000 09:00 -9
## 01/18/2000 09:00 01/18/2000 22:45 -9
## 01/18/2000 22:50 01/19/2000 09:00 0.15
# ...
## 01/25/2000 09:00 01/26/2000 00:35 -9
## 01/26/2000 00:35 01/26/2000 09:00 -9
## 01/26/2000 09:00 01/27/2000 09:00 -9
## 01/27/2000 09:00 01/28/2000 09:00 -9
use strict;
use warnings;
use feature qw( say );
open (my $fh, "<", "temp") || die "Can't open temp: $!";
my ($prevEndDate, @middleRow, $s1, $s2, $mRow) = "";
for my $cRow (<$fh>) {
chomp($cRow);
my @currentRow = split(/\s+/, $cRow);
next if $currentRow[0] =~ /Start/; # skip first row
## col1 col2 col3 col4 col5
## ---- ---- ---- ---- ----
## 01/27/2000 09:00 01/28/2000 09:00 -9
# identify that we're on the last row of a block that
# we're interested in, print it, reset & go to the next row
if ($currentRow[0] eq $prevEndDate && $s2) {
say $cRow;
$s1 = $s2 = 0; # reset states, get ready for next block
next;
}
# identify that we're in the middle of a block that
# we're interested in, so save current row as a middle row
if ($currentRow[0] ne $currentRow[2]) {
$prevEndDate = $currentRow[2];
@middleRow = @currentRow;
$mRow = $cRow;
next;
}
# identified beginning row of a block of rows that we're interested in
$s1 = 1 if ($prevEndDate eq $currentRow[0]);
# identified middle row of a block of rows that we're interested in
$s2 = 1 if ($s1 == 1 && $currentRow[0] eq $currentRow[2]);
say $mRow;
say $cRow;
}
close ($fh);
# vim: set ts=2 nolist :
Quando você executá-lo, verá a seguinte saída:
$ ./timeextract.pl
01/10/2000 09:00 01/11/2000 09:00 -9
01/11/2000 09:00 01/11/2000 21:30 -9
01/11/2000 22:30 01/12/2000 09:00 -9
01/17/2000 09:00 01/18/2000 09:00 -9
01/18/2000 09:00 01/18/2000 22:45 -9
01/18/2000 22:50 01/19/2000 09:00 0.15
01/25/2000 09:00 01/26/2000 00:35 -9
01/26/2000 00:35 01/26/2000 09:00 -9
01/26/2000 09:00 01/27/2000 09:00 -9