The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 07:33 AM
Compare 2 sorted files varungupta Shell Programming and Scripting 7 01-25-2008 01:07 PM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 10:43 PM
Inserting in sorted rows buddyme UNIX for Dummies Questions & Answers 1 10-24-2007 05:26 AM
sorted processes pro Shell Programming and Scripting 7 05-19-2007 03:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-28-2005
krsunderm krsunderm is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 1
comm - sorted result issues

In AIX 5.2, we are attempting to create a delta file by comparing the prior extract to the new extract. We are having some records appear as new when we wouldn't expect it.

Problem appears to be related to the appearance of a new record with a key that is wholly contained in another records key. (Not sure why the key would even matter since we are performing record-level comparisons...)

Ultimately looking to understand:
1) Why are we getting the additional records back?
2) Why does the sort -n (noted below) resolve the issue?


An example probably illustrates the issue best... NOTE(Both sorts use the same syntax.)

Previous Extract (sorted result named prev_extract.dat.srt)
11111|Value A1|Value A2
12345|Value A3|Value A4
12346|Value A5|Value A6
9999|Value A7|Value A8

New Extract (pre-sort)
11111|Value A1|Value A2
12345|Value A3|Value A4
12346|Value A5|Value A6
9999|Value A7|Value A8
123|Value A9|Value A10

Sort New Extract
sort -t"|" -k1,1 New_Extract.dat > New_Extract.dat.srt

New Extract (sorted result)
11111|Value A1|Value A2
123|Value A9|Value A10
12345|Value A3|Value A4
12346|Value A5|Value A6
9999|Value A7|Value A8

Compare the Files
comm -23 New_Extract.dat.srt prev_extract.dat.srt > Extract_addchg.dat


Based on our understanding, the comparison results should show any records that are new (adds) or have been modified. So Extract_addchg.dat should look like:
123|Value A9|Value A10

However, our Extract_addchg.dat actually looks like:
123|Value A9|Value A10
12345|Value A3|Value A4
12346|Value A5|Value A6


If we change our sort commands to a sort -n ... then the 123 record moves well before the 12345 and 12346 and the comm only returns the records desired.


Any explanations?
  #2 (permalink)  
Old 11-29-2005
grasper grasper is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 45
I'd be quite interested in any explanations to that too - changing the pipes (|) to anything else gives the correct result, but I've no idea why this should be.
Sponsored Links
Closed Thread

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 07:47 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