I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd.
The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4".
This is what I use to change the format:
sed -i '' -e "s_\(..\)/\(..\)/\(....\)_\3-\1-\2_" dates.txt
but because of the dual dots (.), it will not match with single digits. I have also tried:
sed -i '' -e "s_\(\d{1,2}\)/\(\d{1,2}\)/\(\d{4}\)_\3-\1-\2_" dates.txt
but somehow that hasn't worked either and returns the same file. So how do I create the correct regex and what is wrong with the second regex?