Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with join command

Status
Not open for further replies.

joker3

IS-IT--Management
Jan 18, 2002
5
0
0
US
I have two files that I would like to join. Here are samples of the two files:

file1:

99998 543
99999 333
100000 215
100003 345

file2:

99998 2009-05
100000 2009-04
100000 2009-04
100001 2009-03

I issue this command:

join -t " " file1 file2 | sort -un > file3

This is the result:

99998 2009-05 543

It doesn't seem to want to join anything after 99998. It should look like this:

99998 2009-05 543
100000 2009-04 215

Thinking that there was more than one space as a delimiter between columns, I used sed to replace any white space with colons :)), then did a join with that as the delimiter and still it stops at 99998.

I am really at a loss as to why this is happening. Does it have anything to do with the numerical values or something? Is there a maximum number that join will actually look at? I doubt it, as I cut the files up and just sorted on numbers over 100000 and it worked fine. So, it has something to do with going from 99998 to 100000, but I can't see the problem.
 
Simply use SORTED files ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for your reply, but I'm not sure I understand what you mean by "Simply use SORTED files". Both files have been sorted numerically, so that the common first column is sorted in Ascending order. Then I join the files.
 
Your files aren't sorted lexicographically, ie 99998 is greater than 100000.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top