awk related question

awk -F ";" 'FNR==NR{a[$0]=$1;next} ($2 in a)' server.list datafile | while read line 
do
        echo ${line}
done

when i run the above, i get this:

1 SERVICE NOTIFICATION: nagiosadmin skysmart-01.sky.net ....

instead of:

[1352267653] SERVICE NOTIFICATION: nagiosadmin skysmart-01.sky.net ....

can someone help me modify the awk statement?

linux/sunos
bash

---------- Post updated at 02:30 PM ---------- Previous update was at 01:14 PM ----------

what i really wanna do is translate the epoch times on the lines.

i need something like this:

cat file | perl -pe "s/(\d+)/localtime($1)/e" | while read line
do
echo $line 
done

i want the resulting lines to have the translated date and time and also the epoch time as well.

something like this:

Wed Nov  7 19:28:46 UTC 2012 [1352267653] SERVICE NOTIFICATION: nagiosadmin skysmart-01.sky.net ....

notice how the translated time is shown, and is followed by epoch time?? any ideas?

I am afraid people won't be able to help much if you don't give an example of the contend of "server.list" & "datafile" files

serverlist contains host names:

skysmart-01.sky.net
skysmart-02.sky.net

datefile contains:

[1351987200] LOG ROTATION: DAILY
[1351987200] LOG VERSION: 2.0
[1351987200] CURRENT HOST STATE: 10.20.20.20;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 3.81 ms
[1351987200] CURRENT HOST STATE: skysmart-01.sky.net;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 11.52 ms
[1351987200] CURRENT HOST STATE: skysmart-01.sky.net;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 8.96 ms

What i want is an output like this:

Wed Nov  7 19:28:46 UTC 2012 [1352267653] SERVICE NOTIFICATION: nagiosadmin skysmart-01.sky.net ....

Try:

echo "${line}"
1 Like

lol wow. i spent all day on this, and the fix is pretty simple.