Sorting af file according to date
Hi,
I want to sort a file according to date but the dates are in jumbled order as, j6dj 2012-02-16 j8nj 2012-02-17 j9nj 2012-02-16 j9xz 2012-02-17 jc2z 2012-02-17 jf30 2012-02-03 jf64 2012-02-17 jh21 2012-02-16 jh4w 2012-02-02 jh73 2012-02-17 How can I sort the file with date in sequential order. Please assist. |
|
Quote:
OP, you need to read the man page on the sort command (type in "man sort" in a terminal window). Pay attention to the "-k" and the "-t" fields. Putting in "sort -k 2 <filename>" will work. Again, read the man page on the sort command if you need it reverse ordered, or need to sort more on the month fields, too. |
$sort -k 2 <filename>
jh4w 2012-02-02 jf30 2012-02-03 j6dj 2012-02-16 j9nj 2012-02-16 jh21 2012-02-16 j8nj 2012-02-17 j9xz 2012-02-17 jc2z 2012-02-17 jf64 2012-02-17 jh73 2012-02-17 |
Quote:
|
sorry for duplicate reply. TBOne already sent. I didn't see it.
|
All times are GMT -5. The time now is 03:25 AM. |