Help with awk script

Hi,

cat test.log
ABC
DEF
DDD
EFG
ABC
DEF
GGG
EFG
XYZ
EFG

I have a file "test.log" and I would like to find the last occurrence of the string DEF and would like to find the value EFG using awk. Can someone help me finding this out?

Thanks,
RK

That seems pretty pointless.

What's the actual objective?

Is there more one each line?
What do you mean by 'value EFG'?

I must agree: your question is rather vague.

However, is this what you're looking for?

$ awk '/DEF/{DEF=NR} /EFG/{EFG=NR} END{print "Last DEF is on line "DEF"\nLast EFG is on line "EFG}' test.log 
Last DEF is on line 6
Last EFG is on line 10
If you like to see the last occurrence of every word:
$ awk '{list[$1]=NR} END{for (string in list){print "Last occurrence of "string": "list[string]}}' test.log |sort
Last occurrence of ABC: 5
Last occurrence of DDD: 3
Last occurrence of DEF: 6
Last occurrence of EFG: 10
Last occurrence of GGG: 7
Last occurrence of XYZ: 9

Eric