Here is the short version of my question: how do you convert comma-separated lists of dates from one format to another? More specifically, I'd like a single one-line command which converts strings of this form:
to strings of the following form:
Now I'll describe the context for my question.
I have a CSV file whose rows contain pairs of adjacent dates in the following format:
I run the following
grep command to extract the pair of dates:
grep -Po '[1-2][0-1][0-9][0-9]/[0-1][0-9]/[0-1][0-9]','[1-2][0-1][0-9][0-9]/[0-1][0-9]/[0-1][0-9]' file.csv`
This results, for example, in strings such as the following:
I am able to convert a single date-string using the
date command as follows:
date -d '2016/05/16' '+%d/%m/%Y'
This produces the desired result:
I tried applying this command to multiple input strings, e.g.:
date -d"2016/05/16","2017/06/15" "+%d-%m-%Y"
But that didn't work. I received the following error message:
Error :- Invalid date - 2016/05/16,2017/06/15'
What I want is a single command which will convert