I am trying to sort by two columns. The first column in an ID, the second is a date in the form yyyy-mm-dd. I need to sort by the ID column, then in ascending order for the date column (earliest date to most recent date compared to today).
Input data:
012-abc 2012-04-25
012-abc 2011-07-14
012-abc 2011-06-07
001-def 2012-04-05
001-def 2011-03-04
043-jke 2009-01-13
043-jke 2009-01-31
043-jke 2012-06-01
043-jke 2011-04-01
Desired output:
001-def 2011-03-04
001-def 2012-04-05
012-abc 2011-06-07
012-abc 2011-07-14
012-abc 2012-04-25
043-jke 2009-01-13
043-jke 2009-01-31
043-jke 2011-04-01
043-jke 2012-06-01
I tried cat file|sort -t -k1 2.1,2.4n -k 2.6,2.7n -k 2.9,2.10n
, but no luck.