How to print in awk matching $1 values ,to $1,$4 example given.?

view full story

http://www.unix.com – Hi Experts, I am trying to get the output from a matching pattern but unable to construct the awk command: file : Code: aa bb cc 11 dd aa cc 33 cc 22 45 68 aa 33 44 44 dd aa cc 37 aa 33 44 67 I want the output to be : ( if $1 match to "aa" start of the line,then print $4 of that line, and if $1 matches to "dd" of start of that line then print $4 of that line). I am trying with this: Code: awk '/^aa/{A=$4};/^dd/{D=$4}END{print A,D}' file But not working!, it is only printing the last finding seems to be. The out put needs to be: Code: (HowTos)