Join Command | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

Join Command

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-10-2013
satyar satyar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 24 January 2013, 9:15 AM EST
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Join Command

Hi,
Please explain the working process of join command.

File 1

Code:
P B
S A
C A

File2

Code:
C B
P A
S D

But the output of join command is...
join File1.txt File2.txt

Code:
P B A
S A D

But I guess the output should be

Code:
P B A
S A D
C A B

Please correct me,if i am worong or missing some thing.

Thanks
Sponsored Links
    #2  
Old 01-10-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 1 November 2014, 4:52 AM EDT
Location: San Jose, CA, USA
Posts: 4,940
Thanks: 186
Thanked 1,657 Times in 1,406 Posts
To work correctly, both files being joined need to be sorted on the fields that are to be used as the matching fields. Since File 1 has the values in the order

Code:
P
S
C

instead of

Code:
C
P
S

for the field used to match for the join, the results are unspecified.
The Following User Says Thank You to Don Cragun For This Useful Post:
satyar (01-10-2013)
Sponsored Links
    #3  
Old 01-10-2013
satyar satyar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 24 January 2013, 9:15 AM EST
Posts: 7
Thanks: 3
Thanked 0 Times in 0 Posts
Thanks a lot...it worked
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to use the the join command to join multiple files by a common column evelibertine UNIX for Dummies Questions & Answers 5 07-05-2012 04:15 PM
how to join two files using "Join" command with one common field in this problem? mindfreak UNIX for Dummies Questions & Answers 2 04-13-2012 05:55 AM
awk command for simple join command but based on 2 columns ruby_sgp Shell Programming and Scripting 2 03-28-2010 07:00 AM
Join command Mish_99 Shell Programming and Scripting 1 10-24-2008 11:27 AM
join (pls help on join command) summer_cherry Shell Programming and Scripting 1 12-31-2007 04:19 AM



All times are GMT -4. The time now is 07:47 AM.