![]() |
|
|
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 |
| Sort command - strange behaviour | miwinter | UNIX for Advanced & Expert Users | 16 | 05-29-2008 08:19 AM |
| Please Help! - Sort command | sumitc | AIX | 1 | 05-01-2008 05:03 PM |
| the sort command | brianm91 | UNIX for Dummies Questions & Answers | 3 | 12-18-2007 08:50 AM |
| help for 'sort' command | ganapati | UNIX for Advanced & Expert Users | 5 | 12-22-2006 02:30 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I have got a file BeforeSort.txt having 40 fields seperated by "|"
First field= RecordType (Value will be P or FP) Second field= CamCode Third field = UpdatingDate Fourth field = ProductType Fifth field = ActionCode (Value may be 01, 02 or 03) Sixth field = ProductCode and so on My requirement is that to sort the above file to get unique records based on Second, Fourth and Sixth fields AND also (1) If there are multiple records for above 3 key fields and with first field RecordType P and FP then take only P record (2) If there are multiple records for above 3 key fields and with first field RecordType P only then take only P record (3) If there are multiple records for above 3 key fields and with first field RecordType FP only then take only FP record I used following sort command to get required records as above : sort -ur -t "|" -k 2,2 -k 4,4 -k 6,6 BeforeSort.txt > AfterSort.txt (I am attaching file BeforeSort.txt herewith) This command is working fine for this small file. ============== Now the actual problem : But when I executed the above command for a real big file PRinLG90_PFP and redirecting the output in file PRinLG90_PFPSort. Then this output file contains some unexpected record for some of ProductCodes. (I have attached file PRinLG90_PFP.txt in zip file PRinLG90_PFP.zip) sort -ur -t "|" -k 2,2 -k 4,4 -k 6,6 PRinLG90_PFP.txt > PRinLG90PFPSort.txt For Example : (1) For sixth field ProductCode R5V2*L503BB6 there are two records with first field RecordType = P & FP and fourth field CamCode = 0049 in file PRinLG90_PFP. And in file PRinLG90_PFPSort there is record of first field RecordType = P (Which is the required and right output record). (2)But for sixth field ProductCode R8V2*L503BB6 there are two records with first field RecordType = P & FP and fourth field CamCode = 0049 in file PRinLG90_PFP. But in file PRinLG90_PFPSort there is record of first field RecordType = FP (While our requirement is that ,it should be P record instead of FP record) I could not understand the above different behaviour of this used sort command. could I take your expert help on this to know the reason/action of this uncertain behaviour of this above sort command. Please help me, because this command is to be used to send a very important and urget delivery Many Thanks & Regards, Pankaj Rai Last edited by pankajrai; 12-21-2005 at 08:04 AM.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|