I am trying to convert all values from the first column of a file that came in milliseconds timestamp to a date format %Y-%m-%d %H:%M:%S. But the output is Di 26. Mai 15:04:00 CEST 2020000. I am using this command:
cat throughput-vs-latency-40K-16.csv | sed 's/^/echo "/; s/\([0-9]\{10\}\)/`date -d @\1`/; s/$/"/' | bash
and this is the file
"Time","pre_aggregate[0]-IN","pre_aggregate[10]-IN",
1590491460000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1590491475000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1590491490000,0,0,0,0,0,0,0,0,
1590491505000,290.51666666666665,290.53333333333336,
1590491535000,1027.15,1027.15,1028.85,1028.8666666666666,
1590491550000,1394.1166666666666,1394.15,1394.15,1394.1333333333334,
1590491565000,1475.5333333333333,1473.3666666666666,
I would like to have the output bellow (please consider only the format and dismiss the correct time conversion):
"Time","pre_aggregate[0]-IN","pre_aggregate[10]-IN",
"2020-05-07 08:05:45",0,0,0,0,0,0,0,0,
"2020-05-07 08:06:45",290.51666666666665,290.53333333333336,
"2020-05-07 08:07:45",1027.15,1027.15,1028.85,1028.8666666666666,
"2020-05-07 08:05:45",1394.1166666666666,1394.15,1394.15,1394.1333333333334,
"2020-05-07 08:08:45",1475.5333333333333,1473.3666666666666,
What am I missing in the sed command to have a date in this format 2020-05-07 08:09:45?