$cat log.txt
#fld names
#Fld: Name Age Sex Lcation
CC 25 M XYZ
BB 21 F XAS
SD 21 M AQW
Output required:
Fld rec1 rec2 rec3
Name CC BB SD
Age 25 21 21
Sex M F M
Lcation XYZ XAS AQW
I tried this
$ sed -e '/^$/d' -e '/^#fld/d' -e 's/#Fld: //' log.txt | awk '{
for(j=1;j<=NF;j++)
{arr[j]=arr[j]"\t"$j}
}
END {for(i in arr)
print arr}
'
Name CC BB SD
Age 25 21 21
Sex M F M
Lcation XYZ XAS AQW
But I am unable to append the header line as I wanted.