Convert from 12 hours (AM/PM) to 24 hours format using awk

Before conversion:

Linux 3.10.0-123.9.2.el7.x86_64 (mo) 11/29/2014 _x86_64_ (8 CPU)

12:00:01 AM CPU %user %nice %system %iowait %steal %idle
12:00:02 AM all 1.64 0.00 1.39 0.00 0.00 96.98
12:00:02 AM 0 1.00 0.00 1.00 0.00 0.00 98.00
12:00:02 AM 1 1.01 0.00 1.01 0.00 0.00 97.98
12:00:02 AM 2 0.99 0.00 1.98 0.00 0.00 97.03
12:00:02 AM 3 1.01 0.00 1.01 0.00 0.00 97.98
12:00:02 AM 4 0.00 0.00 2.00 0.00 0.00 98.00
12:00:02 AM 5 7.00 0.00 1.00 0.00 0.00 92.00
12:00:02 AM 6 0.00 0.00 0.00 0.00 0.00 100.00
12:00:02 AM 7 4.04 0.00 3.03 0.00 0.00 92.93

12:00:02 AM CPU %user %nice %system %iowait %steal %idle
12:00:03 AM all 0.38 0.00 0.76 0.00 0.00 98.86
12:00:03 AM 0 0.00 0.00 0.00 0.00 0.00 100.00
12:00:03 AM 1 0.00 0.00 1.01 0.00 0.00 98.99
12:00:03 AM 2 0.00 0.00 2.04 0.00 0.00 97.96
12:00:03 AM 3 0.00 0.00 1.02 0.00 0.00 98.98
12:00:03 AM 4 0.00 0.00 0.00 0.00 0.00 100.00

CONVERSION:

cat sar.log | awk '{if(NF == 9 && ($2 == "AM" || $2 =="PM")){ cmd="date -d \"\$(date -d \""$1" "$2"\")\" \"+%H:%M:%S\""; cmd | getline val; close(cmd); printf val; print "\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9 }else{ print } }' > sar.24hrsFormat.log

After conversion:

Linux 3.10.0-123.9.2.el7.x86_64 (foca) 11/29/2014 _x86_64_ (8 CPU)

00:00:01 CPU %user %nice %system %iowait %steal %idle
00:00:02 all 1.64 0.00 1.39 0.00 0.00 96.98
00:00:02 0 1.00 0.00 1.00 0.00 0.00 98.00
00:00:02 1 1.01 0.00 1.01 0.00 0.00 97.98
00:00:02 2 0.99 0.00 1.98 0.00 0.00 97.03
00:00:02 3 1.01 0.00 1.01 0.00 0.00 97.98
00:00:02 4 0.00 0.00 2.00 0.00 0.00 98.00
00:00:02 5 7.00 0.00 1.00 0.00 0.00 92.00
00:00:02 6 0.00 0.00 0.00 0.00 0.00 100.00
00:00:02 7 4.04 0.00 3.03 0.00 0.00 92.93

00:00:02 CPU %user %nice %system %iowait %steal %idle
00:00:03 all 0.38 0.00 0.76 0.00 0.00 98.86
00:00:03 0 0.00 0.00 0.00 0.00 0.00 100.00
00:00:03 1 0.00 0.00 1.01 0.00 0.00 98.99
00:00:03 2 0.00 0.00 2.04 0.00 0.00 97.96
00:00:03 3 0.00 0.00 1.02 0.00 0.00 98.98
00:00:03 4 0.00 0.00 0.00 0.00 0.00 100.00