Eu sei como fazer isso usando sed
:
#!/bin/sed -nf
# Read second line & save first two lines to hold
N; h
# Read third line and perform transform
n; s/\([0-9]\+ [a-zA-Z]\+\) /; /g
# Append it to hold
H
# Give hold back
g
# Read fourth line
N
# Transform newlines
s/\n/\t/g
# Print result
p
Ou em uma linha:
sed -n 'N;h;n;s/\([0-9]\+ [a-zA-Z]\+\) /; /g;H;g;N;s/\n/\t/g;p' data.txt