I have a set of date/time strings in the YYYYMMDDHHMMSS format that I want to convert to something readable by the date
utility. Usually, I can do something li
Try this:
echo "20101106213245" | sed -r 's/^.{8}/& /;:a; s/([ :])(..)\B/\1\2:/;ta'
Result:
20101106 21:32:45
You want some hyphens, too?
echo "20101106213245" | sed -r 's/^.{4}/&-/;:a; s/([-:])(..)\B/\1\2:/;ta;s/:/-/;s/:/ /'
Result:
2010-11-06 21:32:45
2010-11:06:21:32:45
-> 2010-11-06:21:32:45
)2010-11-06:21:32:45
-> 2010-11-06 21:32:45
)