The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 06-04-2008
ripat ripat is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2006
Location: Belgium
Posts: 438
The problem with your file is that the date is not ISO i.e. it is not sortable as it is. You have to split it and sort it first on the YYYY, then on MM and, finaly on DD. That's exactly what the following command does. It sorts on the 3rd field from character 7 to character 10 then on char. 4 to 5 etc...


Code:
sort -u -t"|" -k 3.7,3.10n -k 3.4,3.5n -k 3.1,3.2n file


Last edited by ripat; 06-04-2008 at 05:19 AM..