Get last column value with AWK for a variable
Posted on 2013-01-16
I have the following log file with input such as:
DBNAME=K1DB LAST=16.01.2012:23:30:00 TYPE=C
DBNAME=K2DB LAST=16.01.2012:11:30:00 TYPE=C
DBNAME=K3DB LAST=16.01.2012:12:30:00 TYPE=C
DBNAME=K1DB LAST=16.01.2013:14:30:00 TYPE=O
DBNAME=K1DB LAST=16.01.2013:16:30:00 TYPE=C
I have a ksh variable DBNAME that has the value K1DB for instance.
With awk I need to extract the last date (16.01.2013:16:30:00) within that logfile for that specific variable i.e. K1DB.
Can you please show me how to achive that? I have tried different things throughout the day with no success. A solution would be tremedously welcome.