Changes in code to provide proper result with one additional fiield

view story

http://www.unix.com – Hi all I am using following code to get results for brand name drug target name and generic name from my attached fiile Code: awk 'k>0 {if (a[k] && k==2) {print a[1]":"a[2]":"a[3]; a[1]=a[2]=a[3]="";} a[k]=a[k]?a[k]","$0:$0; k=0;} /^# Drug_Target_.*_Gene_Name/ {k=3;} /^# Generic/ {k=1;} /^# Brand_Name/ {k=2;} END {if (a[1]) print a[1]":"a[2]":"a[3];}' drugbank.txt >drugbank3.txt But when I change the code to additional field Drug Type. It is not giving me proper results can anybody guide to make changes (HowTos)