Hey folks
I am doing some NSCA log parsing and I want to get an output like this:
2011-Feb-18:11:00:07
2011-Feb-18:11:00:07
2011-Feb-18:11:00:07
2011-Feb-18:11:00:08
2011-Feb-18:11:00:08
converted to this:
1298026807
1298026807
1298026807
1298026808
1298026808
Of course I'm making it hard for myself by cramming it into a shell one liner - this is where I'm at:
The following will create the formatted-date output:
Code:
sort -b -k4.9,4.12 -k4.5b,4.7Mb -k4.2,4.3 -k4.14,4 foo.log| awk -F '[ \[\/:]' '{print $7"-"$6"-"$5":"$8":"$9":"$10}'
and I want to pass that into the second parameter of 'date -j' like this:
Code:
date -j -f "%Y-%b-%d:%T" "+%s" "<pass each line into here>"
I have tried this, but it treats the entire output as a single line, then plops a timestamp on the end (I think):
Code:
sort -b -k4.9,4.12 -k4.5b,4.7Mb -k4.2,4.3 -k4.14,4 foo.log| date -j -f "%Y-%b-%d:%T" "+%s" "`awk -F '[ \[\/:]' '{print $7"-"$6"-"$5":"$8":"$9":"$10}'`"
I'm pretty sure this is dead easy, but I just wasted an hour on it
Any ideas?
christo