![]() |
|
|
|||||||
| 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 |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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? |
| Forum Sponsor | ||
|
|