#!/usr/bin/gawk -f #/* vim: set filetype=awk : */ -*- awk -*- BEGIN{ FS="," #Prep="cat" #Learn="nbk" #Data="a2b/breast-cancer" #Column=17 } { sub(/#.*/,"")} /^[ \t]*$/{next} { #print Prep if(($1 == Data)&&($2==Learn)&&($3==Prep)&&(Column > 0)&&(Column <= NF)) { #print $2 " & " $1 "," $Column print $1 "&" $2 "&" $3 "," $Column #print $Column } }