I have a log file:
href="http://pastebin.com/raw.php?i=cdUpTqNV" rel="nofollow
noreferrer">http://pastebin.com/raw.php?i=cdUpTqNV
the
first column, before the "ASDF" is the same time, as in the given row, but in unix time
[i think it's easier to do this with unix time].
I just need the lines
what was in the last 2 minutes:
Ending: 07:55:08 - the last time in the
logfile
Starting: 07:53:09 - at most 2 minutes before the last log line in
the logfile
The output of the pastebined text would be:
/>1295938389ASDF 01 25 07:53:09 router authpriv.notice dropbear[20673]:
password auth succeeded for 'root' from 192.168.1.201:43822
/>1295938401ASDF 01 25 07:53:21 router daemon.info dnsmasq-dhcp[1140]:
DHCPREQUEST(br-lan) 192.168.1.201 01:2c:23:c3:32:f3
/>1295938401ASDF 01 25 07:53:21 router daemon.info dnsmasq-dhcp[1140]:
DHCPACK(br-lan) 192.168.1.201 01:2c:23:c3:32:f3
/>1295938508ASDF 01 25 07:55:08 router daemon.info dnsmasq-dhcp[1140]:
DHCPREQUEST(br-lan) 192.168.1.201 01:2c:23:c3:32:f3
/>1295938508ASDF 01 25 07:55:08 router daemon.info dnsmasq-dhcp[1140]:
DHCPACK(br-lan) 192.168.1.201 01:2c:23:c3:32:f3
How to do
this using only minimal *nix tools? [it's an OpenWrt router, no perl :(
]
so, how to do this: output only line(Last log line time -
120sec)?
Thank you!
Answer
Give this a
try:
last=$(sed -n
'$s/^\([0-9]\+\).*/\1/p')
awk -F ASDF -v last=$last '$1 >= last -
120'
Comments
Post a Comment