sort question

Joel Hammer Joel
Mon May 17 11:48:55 PDT 2004


I want to sort the contents of my .calendar file for pcal.
The entries looks like this:
01/04/04 Item
1/3/3 Item
And so on.
I want to wind up with all the dates in proper order in the file.
I have two problems I cannot figure out.
First, when trying just to sort the fields numerically, using this sort
of construction:
     sort -n -t'/' -n +1
will sort the file numerically by the day of the month.
But, 
     sort -n -t'/' -n +0-2
will sort the month (The first field) numerically 
but the next two fields are sorted like strings. Is there a way to make all
the fields sort numerically?

Second, is there way to sort the fields in random order, that is, year,
month, and day?

Thanks,
Joel



More information about the Linux-users mailing list