http://pastebin.com/raw.php?i=rCLH4r4M
I have a text file: "hogyaza.txt".
I want to convert the "normal dates" in it [only at the line starting] to unix time. i know how to "convert" one line:
$ ONELINE='2011-01-24 19:13:19ASDF 01 24 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPDISCOVER(br-lan) 192.168.1.201 00:1b:37:a8:74:f1'; date +%s -d "$(echo $ONELINE | awk -F "ASDF" '{print $1}')"
1295892799
$
But i need it in this format:
1295892799ASDF 01 24 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPDISCOVER(br-lan) 192.168.1.201 00:1b:37:a8:74:f1
or better, this format:
1295892799 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPDISCOVER(br-lan) 192.168.1.201 00:1b:37:a8:74:f1
here's the file:
$ cat hogyaza.txt
2011-01-24 19:13:19ASDF 01 24 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPDISCOVER(br-lan) 192.168.1.201 00:1b:37:a8:74:f1
2011-01-24 19:13:19ASDF 01 24 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPOFFER(br-lan) 192.168.1.201 00:1b:37:a8:74:f1
2011-01-24 19:13:19ASDF 01 24 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPREQUEST(br-lan) 192.168.1.201 00:1b:37:a8:74:f1
2011-01-24 19:13:19ASDF 01 24 19:13:19 router daemon.info dnsmasq-dhcp[1140]: DHCPACK(br-lan) 192.168.1.201 00:1b:37:a8:74:f1
$
Does anybody know how to convert the e.g.: "^2011-01-24 19:13:19" dates to unix format in the txt?
Thank you!
p.s.: it's needed on an openwrt router, so no perl :((( no space for it on the flash
If you know how to convert one line, then a simple loop will handle all the lines for you:
This gives output that looks like: