I am writing a bash script that reads a file line by line.
The file is a .csv file which contains many dates in the format DD/MM/YYYY but I would like to change the
Try this using sed:
line='Today is 10/12/2010 and yesterday was 9/11/2010' echo "$line" | sed -r 's#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})#\3-\2-\1#g' OUTPUT: Today is 2010-12-10 and yesterday was 2010-11-9
PS: On mac use sed -E instead of sed -r
sed -E
sed -r