Combine these two into one liner awk?

view full story

http://www.unix.com – ignore the simplicity of the foo file, my actual file is much more hardcore but this should give you the jist of it. need to combine the two awks into one liner. essentially, need to return the value of one particular field in a file that has multiple comma separated fields. thanks guys Code: cat foo make,model,engine,trim,value bmw,530,3.0,sport,20000 merk,E180,1.8,amg,16000 head -n1 foo|awk -F, '{for(i=1;i<=NF;i++)if($i==v)print i}' v=engine 3 cat foo |awk -F, '{print $1 " "$3}' bmw 3.0 merk 1.8 (HowTos)