Bash: convert iso dates to d:m:y

bashconvertformattingtime

I have a program, which produces output like this (iso format dates):

2010-06-04 15:48:17 +0200
2010-06-04 12:34:39 +0200
2010-02-01 14:02:44 +0200
2010-06-04 12:21:19 +0200
2010-06-04 12:21:04 +0200
2009-05-02 15:38:14 +0200
2009-03-02 15:38:09 +0200
2010-06-04 14:45:00 +0200
...

How do I convert the output to unique, sorted dates:

2010-06-04
2010-02-01
2009-05-02
2009-03-02

And then, on each unique date run: mycommand --withargs [yyyy-mm-dd]?

Best Answer

You can do the following:

$ <iso_command> | awk '{print $1}' | sort -u | xargs -n 1 mycommand --withargs