HP IML log formatting

HP hardware
Linux SLES version 10
shell script, ksh or sh

I am taking the output of the IML log and ultimately want to find only entries 30 days old. I am getting some unexpected results along the way.

hpasmcli -s "SHOW IML"

Event: 4 Added: 06/12/2012 13:56
INFO: Maintenance Note - IML Cleared (iLO 3 user:hpfe).

Event: 5 Added: 06/23/2012 15:06
CRITICAL: CPU - Uncorrectable Machine Check Exception (Board 0, Processor 1, APIC ID 0x00000010, Bank 0x00000004, Status 0xFA000000'00070F0F, Address 0x00000000'00000000, Misc 0xC0040FFE'01000000).

Event: 6 Added: 06/23/2012 15:06
CRITICAL: CPU - Uncorrectable Machine Check Exception (Board 0, Processor 2, APIC ID 0x00000021, Bank 0x00000004, Status 0xBA000000'00070F0F, Address 0x00000000'00000000, Misc 0xC0040FFE'01000000).

Event: 7 Added: 06/23/2012 15:06
CAUTION: POST Messages - POST Error: The system experienced an unexpected reboot. The Integrated Management Log (IML) may contain an entry indicating additional information about this reboot..

Here is my code so far.

for LINE in `hpasmcli -s "SHOW IML" |sed "s/'//g"  |xargs -L 2 |awk '{print $4, $5}'` ; do
     echo $LINE
#     date --date "${LINE}" +%s
done

I am using the xargs command to get each 2-line set all together on one line to make it easier to work with. The sed command is to remove an unclosed single quote.

when I run this script I get this.

06/12/2012
13:56
06/23/2012
15:06
06/23/2012
15:06
06/23/2012
15:06
Why is it wrapping the date and the time on 2 different lines? I want them all on the same line!!

# hpasmcli -s "SHOW IML" |sed "s/'//g" |xargs -L 2 |awk '{print $4, $5}'
06/12/2012 13:56
06/23/2012 15:06
06/23/2012 15:06
06/23/2012 15:06
Here is what it should look like.

Once I get this worked out I want to write the date as epoch at the end of the line, take today's date and go back 30 days and compare, dropping any line that is over 30 days long.

That is a useless use of backticks.

The 'for' loop will split on all whitespace. It also has other faults.

To read line by line, use a while-read loop.

code | while read LINE
do
...
done

not pretty, but its working

hpasmcli -s "SHOW IML" |sed "s/'//g"  |xargs -L 2 > /tmp/file1
hpasmcli -s "SHOW IML" |sed "s/'//g"  |xargs -L 2 |awk '{print $4, $5}' |while read LINE; do
     date --date "${LINE}" +%s > /tmp/file2
done
     paste /tmp/file1 /tmp/file2

just need to optimize it now

Well, you can cut out one hpasmcli call since you already saved the output to file:

hpasmcli -s "SHOW IML" |sed "s/'//g"  |xargs -L 2 > /tmp/file1

awk '{print $4, $5}' /tmp/file1 |while read LINE; do
     date --date "${LINE}" +%s > /tmp/file2
done

paste /tmp/file1 /tmp/file2