Govins Govins - 7 months ago 13
Bash Question

Date split in linux using awk

Date split/conversion in linux using awk.

input

19-AUG-10 05.56.48 PM


desired output

20100819T17:56:48

Answer

GNU awk:

echo "19-AUG-10 05.56.48 PM" | awk -F- '{ gsub(/\./,":");system("date -d\"" $2"-"$1"-"$3 "\" +%Y%m%dT%H:%M:%S")}'