1

Convert date time (12h) to mysql datetime format in CSV file using bash

view story
linux-howto

http://stackoverflow.com – I have a CSV file with date time formatted like this: 8/2/2012 1:34:01 PM I need to find all the occurrences (probably regex) of such date and convert it (in file) to mysql default datetime format (2012-08-02 13:34:01). I found that date --date="8/2/2012 1:34:01 PM" +"%F %T" is working properly and I'm getting correct result. The solution would be to find all the occurrences of wrongly formatted date and pass it through this above date function. Single line from CSV file looks like this: "Data 1","Data 2","Data 3","Data 4","100000000100","100000002263","10/31/2012 10:02:03 AM","1/29/ (HowTos)