Aqui está um simples ksh:
{
read t1 t2 t3 t4
maxlen=$(printf "%s\n" ${#t1} ${#t2} ${#t3} ${#t4} | sort -n | tail -1)
fmt=$(printf "%%-%ds -> %%s" $maxlen)
read line
while read date time tel id type; do
printf "$fmt\n" $t1 "$date $time" $t2 $tel $t3 $id $t4 $type
print "\n\n\n---\n\n"
done
} < orig-file.txt
Atualizar para o número flexível de campos:
Eu substituo o espaço no campo datetime para facilitar a análise
sed '3,$s/ /@@/' orig-file.txt |
{
read line
set -A headings $line
max=0
for head in "${headings[@]}"; do (( max < ${#head} )) && max=${#head}; done
fmt=$(printf "%%-%ds -> %%s" $max)
read line
while read line; do
set -A fields $line
i=0
while (( i < ${#headings[@]} )); do
printf "$fmt\n" ${headings[$i]} ${fields[$i]} | sed 's/@@/ /'
(( i=i+1 ))
done
print "\n\n\n---\n\n"
done
}