The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


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 !!


Other UNIX.COM Threads 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 04:33 AM
Compare 2 sorted files varungupta Shell Programming and Scripting 7 01-25-2008 09:07 AM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 06:43 PM
Inserting in sorted rows buddyme UNIX for Dummies Questions & Answers 1 10-24-2007 02:26 AM
sorted processes pro Shell Programming and Scripting 7 05-19-2007 12:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-2005
Registered User
 

Join Date: Nov 2005
Posts: 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-29-2005
Registered User
 

Join Date: Sep 2005
Posts: 45
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB 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 -7. The time now is 11:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102