The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk, join or sed jkl_jkl Shell Programming and Scripting 1 04-15-2008 02:55 AM
Join jazz8146 UNIX for Dummies Questions & Answers 5 01-29-2008 07:42 AM
join (pls help on join command) summer_cherry Shell Programming and Scripting 1 12-31-2007 01:19 AM
Use non alphanumerics in join s0460205 UNIX for Dummies Questions & Answers 1 12-16-2005 03:03 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #8 (permalink)  
Old 05-08-2008
Registered User
 

Join Date: May 2008
Posts: 7
Stumble this Post!
drl,

I noticed you used sh in your script and I used bash when I did my interactive session. So I changed my shell to sh but still join did not work. Here is the session history:

[chenz@beta binned]$ echo $0
bash
[chenz@beta binned]$ sh
sh-3.1$ echo $0
sh
sh-3.1$ cat data1
rs10051507 5 q21.3
rs10051514 5 p15.32
rs10051527 5 q21.2
rs1005152 7 q21.3
rs10051540 5 q21.3
rs10051548 5 q21.1
rs1005155 X q27.3
rs10051594 5 q34
sh-3.1$ cat data2
rs1003456 3
rs1005152 3
sh-3.1$ sort data1>t1
sh-3.1$ sort data2>t2
sh-3.1$ join t1 t2
sh-3.1$
Reply With Quote
Forum Sponsor
  #9 (permalink)  
Old 05-08-2008
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 509
Stumble this Post!
Hi.

Yes, I think the LC_ALL and LANG settings may have something to do with it. It looks like you are running RedHat 5.

Note that your default LANG is neither C nor null, both of which worked for me.

You can try entering this interactively:
Code:
LC_ALL=C ; LANG=C ; export LC_ALL LANG
and then enter the steps again.

I have no additional thoughts. Perhaps someone will stop by with some advice ... cheers, drl
Reply With Quote
  #10 (permalink)  
Old 05-08-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 541
Stumble this Post!
As drl pointed out file1 and file 2 are not sorted. Sort both of 'em before trying the join operation to get the expected result.

Code:
sort -k1,1 file1 > file1srt

sort -k1,1 file2 > file2srt

join -j 1 file1srt file2srt
Reply With Quote
  #11 (permalink)  
Old 05-08-2008
Registered User
 

Join Date: May 2008
Posts: 7
Stumble this Post!
Thanks to Shamrock -- it's working now using the following syntax:

sort -k1,1 file1 > file1srt

sort -k1,1 file2 > file2srt

join -j 1 file1srt file2srt

Out of curiosity: why the following not working?

sort -k1 file1 > file1srt

sort -k1 file2 > file2srt

join -j 1 file1srt file2srt

In any case, sincerely thanks to both drl and shamrock.
Reply With Quote
  #12 (permalink)  
Old 05-08-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 541
Stumble this Post!
Quote:
Originally Posted by gamma_user View Post
Out of curiosity: why the following not working?

sort -k1 file1 > file1srt

sort -k1 file2 > file2srt

join -j 1 file1srt file2srt
"sort -k1" sorts file on the entire line. The start field is 1 but as no end field is given it defaults to the end of the line. "sort -k1,1" specifies the start and end field to be 1 and so its output is different from the "sort -k1" case.
Reply With Quote
  #13 (permalink)  
Old 05-09-2008
Registered User
 

Join Date: May 2008
Posts: 7
Stumble this Post!
Thanks a lot, shamrock.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux, solaris

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:12 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 Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0