I have a table ABC with 4 columns and below data
Col1,Col2,Col3,Col4
prod,10,12,joba
prod,10,11,jobb
qa,10,12,jobc
I want to create an output file like this
Server:prod
StartTime:10
EndTime:12
JobName:joba
Server:prod
StartTime:10
EndTime:11
JobName:jobb
Server:qa
StartTime:10
EndTime:12
JobName:jobc
The number of rows can change
Can some one help
nawk -F, -v h='Server,StartTime,EndTime,JobName' 'BEGIN{n=split(h,hA)}{for(i=1;i<=NF;i++) print hA,$i;print ""}' OFS=: myFile
~/unix.com$ awk -F\, 'NR>2{print "Server:"$1"\nStartTime:"$2"\nEndTime:"$3"\nJobName:"$4"\n"}' file
$ perl -F, -ane '($.<3)&& next;open O,">>out.dat";print O "Server:$F[0]\nStartTime:$F[1]\nEndtime:$F[2]\nJobName:$F[3]\n\n";close O' input
$
$ cat out.dat
Server:prod
StartTime:10
Endtime:12
JobName:joba
Server:prod
StartTime:10
Endtime:11
JobName:jobb
Server:qa
StartTime:10
Endtime:12
JobName:jobc
$
$