How to sort a field in a file having date values

Hi All,

I am having a pipe delimited file .In this file the 3rd column is having date values.I need to get the min date and max date from that file.

I have used
cut -d '|' test.dat -f 3|sort -u

But it is not sorting the date .How to sort the date column using unix commands

Thanks
Deepak

Show us some lines of your delimeted file, please.

I have used a small file for testing

A line in the file looks like thsi
deepak|55445|12-02-2008|alappuzha

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...

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

Thanks a lot ...