Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I have been struggling with this for some time now, but can't quite get it. I have two files that I would like to join on a common field. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    14

    join of two files on common field is not working correctly


    Hello,

    I have been struggling with this for some time now, but can't quite get it. I have two files that I would like to join on a common field. The common field is the first field in both and numerical. I have presorted each file and the result is that the first field in each file is sorted numerically. So, then I run a join:

    join file1 file2 > file3

    The result is 1) the resulting file misses a group of lines that are common based on the first field, and only goes up to 99998, when both inividual files have an ending number of 140876. 2) 'join: file 2 is not in sorted order'

    As I said, both files are numerically sorted and have the same ending number in the first field, not that it should matter, just for explaining what is happening.

    I have read on the forums about sorting nulmerically vs lexicographically (alphabetical). The latter doesn't work, so what am I missing? Here are subsets of each file:

    file1:

    7046 150
    7047 150
    7048 150
    7049 150
    7050 150
    7051 150
    7052 150
    7053 150
    7054 150
    7055 333
    7056 333
    .
    .
    .
    140876 543
    file 2:


    7046 2003-04
    7047 2003-04
    7048 2003-04
    7049 2003-04
    7050 2003-04
    7051 2003-04
    7052 2003-04
    7053 2003-04
    7054 2003-04
    7055 2003-04
    7056 2003-04
    .
    .
    .
    140876 2012-09

    file 3: Misses all of the above, starts with 992, ends with 9998

    This has to have something to do with the sort order, or there are too many rows, or.....?

    Thank you.

  2. #2
    Just Joined!
    Join Date
    Aug 2012
    Location
    Argentina
    Posts
    3
    try
    Code:
    cat file1 file2 > file3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •