Hi Experts,
I am trying to get the output from a matching pattern but unable to construct the awk command:
file :
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:
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:
aa 11
dd 33
aa 44
dd 37
aa 67
Thanks.