How to format a date string

I have a file tmp.out with contents:
20080812 02:41:07
20080812 05:03:04
20080812 05:46:16

How do I format the contents such as:
2008-08-12 02:41:07
2008-08-12 05:03:04
2008-08-12 05:46:16

Thanks,

  • CB

One way with awk:

awk '{print substr($1,1,4)"-"substr($1,5,2)"-"substr($1,7,2), $2}' tmp.out

Regards

Thanks... it worked like a charm.

  • CB