![]() |
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 |
| need help in sort | ali560045 | Shell Programming and Scripting | 2 | 12-04-2007 07:38 AM |
| sort | prasathlogu | UNIX for Dummies Questions & Answers | 1 | 10-08-2007 06:56 AM |
| du -h | sort ? | fongthai | Shell Programming and Scripting | 6 | 11-02-2006 08:59 PM |
| How do i sort? | abhijeetkul | Shell Programming and Scripting | 1 | 12-22-2005 03:49 AM |
| 2nd sort key | whatisthis | UNIX for Dummies Questions & Answers | 1 | 10-20-2004 10:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sort -k
Hi all
Iīm stuck with the sort command and would like to ask you for help. Iīm using the following command on the following file: Code:
sort -t "|" -k 1 -k 9 -k 17r file file: 21833 |23901602|01|2| | |1|0056047507|N| | | | | | | |IN| ... 21837 |20058199|01|6| | |1|0003110782|N| | | | | | | |CR| 21837 |21500283|01|2| | |1|0006044233|Y| | | | | | | |CR| 21837 |23688532|01|2| | |1|0038096691|N| | | | | | | |IN| 21837 |23759215|01|2| | |1|0044596008|Y| | | | | | | |IN| ... 21872 |23809251|01|2| | |1|0048651199|N| | | | | | | |IN| 22224 |20085858|01|4| | |1|0003180165|N| | | | | | | |IN| aaaaa |24053243|01|2| | |1|0068367876|N| | | | | | | |IN| The expected result is the following (check the four lines in the middle): Code:
21833 |23901602|01|2| | |1|0056047507|N| | | | | | | |IN| ... 21837 |23688532|01|2| | |1|0038096691|N| | | | | | | |IN| 21837 |20058199|01|6| | |1|0003110782|N| | | | | | | |CR| 21837 |23759215|01|2| | |1|0044596008|Y| | | | | | | |IN| 21837 |21500283|01|2| | |1|0006044233|Y| | | | | | | |CR| ... 21872 |23809251|01|2| | |1|0048651199|N| | | | | | | |IN| 22224 |20085858|01|4| | |1|0003180165|N| | | | | | | |IN| aaaaa |24053243|01|2| | |1|0068367876|N| | | | | | | |IN| Cheers Last edited by Indalecio; 03-16-2007 at 03:39 AM.. |
|
||||
|
Thanks anbu, but this doesn't work. The second sorting rule is not applying:
Code:
21833 |23901602|01|2| | |1|0056047507|N| | | | | | | |IN| ... 21837 |23688532|01|2| | |1|0038096691|N| | | | | | | |IN| 21837 |23759215|01|2| | |1|0044596008|Y| | | | | | | |IN| 21837 |20058199|01|6| | |1|0003110782|N| | | | | | | |CR| 21837 |21500283|01|2| | |1|0006044233|Y| | | | | | | |CR| ... 21872 |23809251|01|2| | |1|0048651199|N| | | | | | | |IN| 22224 |20085858|01|4| | |1|0003180165|N| | | | | | | |IN| aaaaa |24053243|01|2| | |1|0068367876|N| | | | | | | |IN| |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|