Apr 21, 2004 #1 toomee Technical User Jan 28, 2003 10 TH I have data like this, a,1,b,2,c,3,d,4,e,5 a,11,b,12,c,13,d,14 b,21,c,22,d,23 a,31,b,32,d,33 I need only the fields that follow b and d like, 2|4 12|14 21|23 32|33 Could anyone help me? Thank you
I have data like this, a,1,b,2,c,3,d,4,e,5 a,11,b,12,c,13,d,14 b,21,c,22,d,23 a,31,b,32,d,33 I need only the fields that follow b and d like, 2|4 12|14 21|23 32|33 Could anyone help me? Thank you
Apr 21, 2004 #2 PHV MIS Nov 8, 2002 53,708 FR Something like this ? awk -F',' '{ b="";d="" for(i=1;i<NF;++i){ if($i=="b")b=$(i+1) if($i=="d")d=$(i+1) };printf "%s|%s\n",b,d }' /path/to/inputfile Hope This Help, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 Upvote 0 Downvote
Something like this ? awk -F',' '{ b="";d="" for(i=1;i<NF;++i){ if($i=="b")b=$(i+1) if($i=="d")d=$(i+1) };printf "%s|%s\n",b,d }' /path/to/inputfile Hope This Help, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884