I have a large file which contains data in specific format. I want to convert date format with different one.
from: YYYY-MM-DD hh:mm:ss.sss
To: YYYY-MM-DDThh:mm:ss.sss000+00:00
I can print out the desired format using awk
awk -F " " '{print substr($1,0,4)"-"substr($1,6,2)"-"substr($1,9,2)"T"substr($2,1,2)":"substr($2,4,2)":"substr($2,7,6)"000+00:00"}' my-file.txt
but struggling to replace it inline. Also have heard that sed
has similar capability to do inline replacement.
I have tried running below sed command but its not working -
sed 's/\([0-9]{4}-[0-9]{2}-[0-9]{2}\s\) \([0-9]{2}:[0-9]{2}:[0-9]{2}\s\) \1/T\2 /g'
It says unterminated
s' command`
Any suggestion/pointers are appreciated.