The UNIX and Linux Forums  

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



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-21-2005
pankajrai pankajrai is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 1
Unhappy Help me to resolve uncertian behaviour of a sort command

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
Attached Files
File Type: txt BeforeSort.txt (4.2 KB, 19 views)
File Type: zip PRinLG90_PFP.zip (1.61 MB, 2 views)

Last edited by pankajrai; 12-21-2005 at 08:04 AM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0