Usando o Perl:
perl -lane 'BEGIN{ print("\t\tT1\tF2\tI1\tF3\tRegulated F2\tFR T1"); $, = "\t" } if($F[0] =~ /00:00:t[0-9]+/){ @f[0] = $F[0]; @f[1] = $F[2]; for($i = 2; $i < 7; $i++) { $_ = <>; @F=split(); if($i < 5){ $f[$i] = $F[1] }else{ $f[$i] = $F[2] } } print(@f) }' file
Script expandido (para tornar-se executável com chmod +x script.pl
e para ser executado com ./script.pl file
):
#!/usr/bin/perl -lan
BEGIN {
print("\t\tT1\tF2\tI1\tF3\tRegulated F2\tFR T1");
$, = "\t"
}
if($F[0] =~ /00:00:t[0-9]+/) {
$f[0] = $F[0];
$f[1] = $F[2];
for($i = 2; $i < 7; $i++) {
$_ = <>;
@F=split();
if($i < 5) {
$f[$i] = $F[1]
}
else {
$f[$i] = $F[2]
}
}
print(@f)
}
Você pode ajustar o cabeçalho modificando print("\t\tT1\tF2\tI1\tF3\tRegulated F2\tFR T1");
e o separador do campo de saída modificando $, = "\t"
.
% cat file
19-08-02 Name appel ok hope local merge (mk)
juin nov sept oct
00:00:t1 T1 299 0 24 8 3 64
F2 119 0 11 8 3 62
I1 25 0 2 9 4 64
F3 105 0 10 7 3 61
Regulated F2 0 0 0
FR T1 104 0 10 7 3 61
00:00:t2 T1 649 0 24 8 3 64
F2 119 0 11 8 3 62
I1 225 0 2 9 4 64
F3 165 0 10 7 3 61
Regulated F2 5 0 0
FR T1 102 0 10 7 3 61
20-08-02 Name appel ok hope local merge (mk)
juin nov sept oct
00:00:t5 T1 800 0 24 8 3 64
F2 111 0 11 8 3 62
I1 250 0 2 9 4 64
F3 105 0 10 7 3 61
Regulated F2 0 0 0
FR T1 100 0 10 7 3 61
% perl -lane 'BEGIN{ print("\t\tT1\tF2\tI1\tF3\tRegulated F2\tFR T1"); $, = "\t" } if($F[0] =~ /00:00:t[0-9]+/){ @f[0] = $F[0]; @f[1] = $F[2]; for($i = 2; $i < 7; $i++) { $_ = <>; @F=split(); if($i < 5){ $f[$i] = $F[1] }else{ $f[$i] = $F[2] } } print(@f) }' file
T1 F2 I1 F3 Regulated F2 FR T1
00:00:t1 299 119 25 105 0 104
00:00:t2 649 119 225 165 5 102
00:00:t5 800 111 250 105 0 100
%