![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| read from a file and calculate values for a specified field | lucho_1 | Shell Programming and Scripting | 3 | 03-11-2008 07:24 PM |
| how to sort paragraphs by date within a file | nabmufti | Shell Programming and Scripting | 1 | 02-13-2008 05:33 PM |
| loop through the directory for files and sort by date and process the first file | dsdev_123 | AIX | 1 | 01-30-2008 05:31 PM |
| sort a file by date using perl | esham | Shell Programming and Scripting | 4 | 04-14-2005 01:04 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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 04:19 AM.. |
|
||||
|
Thanks a lot ...
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|