My join command only joins the first few lines!!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers My join command only joins the first few lines!!
# 1  
Old 05-16-2011
My join command only joins the first few lines!!

Hi new to all this so bear with me.

I have two lists. List A has the old names and some values for each of the names

e.g.
List A:
Code:
snpa 3.2
snpb -2
snpc 0


List B has old names and new names equivalent:
Code:
snpa rs1234
snpb rs2345
snpc re3456

Now I have over 50,000 lines in each and want it to end up as

Final list after join.
Code:
rs1234 3.2
rs2345 -2
rs3456 0

The code I have been using:
Code:
join fileA.txt filebB.txt | awk '{print $3 ,$2}' | sort -k1 > final_list.txt

But all I get is the first few lines rather the 50k lines I should get.

Why is it working but only for a small amount of the data?

Last edited by Franklin52; 05-16-2011 at 08:39 AM.. Reason: Please use code tags
# 2  
Old 05-16-2011
Try:
Code:
join -11 -21 -o2.2,1.2 <(sort -k1 fileA.txt) <(sort -k1 fileB.txt) > final_list.txt

# 3  
Old 05-16-2011
Quote:
Originally Posted by bartus11
Try:
Code:
join -11 -21 -o2.2,1.2 <(sort -k1 fileA.txt) <(sort -k1 fileB.txt) > final_list.txt


Genius!! Thanks so much

What is the difference? What is this line doing that the other wasn't?

Would be good to learn a bit as well as just have the solution.

Thanks once again.
# 4  
Old 05-16-2011
join needs the files to be sorted. This is what <(sort -k1 fileA.txt) <(sort -k1 fileB.txt) is doing Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join Lines

Hi how do I join files like below in script. Thanks, Ashan there are may line like this in the file. zone name DR_TMP_A_sev1_3eA vsan 200 pwwn 50:00:09:73:f0:16:35:08 pwwn c0:50:76:08:6e:dc:00:16 zone name DR_TMP_A_SVR2_3eA vsan 200 pwwn 50:00:09:73:f0:16:35:08 pwwn... (4 Replies)
Discussion started by: ashanabey
4 Replies

2. UNIX for Dummies Questions & Answers

How to use the the join command to join multiple files by a common column

Hi, I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column). I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies

3. UNIX for Dummies Questions & Answers

how to join two files using "Join" command with one common field in this problem?

file1: Toronto:12439755:1076359:July 1, 1867:6 Quebec City:7560592:1542056:July 1, 1867:5 Halifax:938134:55284:July 1, 1867:4 Fredericton:751400:72908:July 1, 1867:3 Winnipeg:1170300:647797:July 15, 1870:7 Victoria:4168123:944735:July 20, 1871:10 Charlottetown:137900:5660:July 1, 1873:2... (2 Replies)
Discussion started by: mindfreak
2 Replies

4. Shell Programming and Scripting

join two lines

I want to join this two lines but only when after him I have nothing or a comma Yes, I know Jonesy, and I'll give him about one more minute. this two lines must become Yes, I know Jonesy, and I'll give him about one more minute. thank you very much (11 Replies)
Discussion started by: thailand
11 Replies

5. Shell Programming and Scripting

join 2 lines

hi all i have sample and i need script to do this /dev/xxx oracle test /dev/sap 9999 000 88 99 i need the out put like this /dev/xxx oracle test /dev/sap 9999 000 88 99 can any one provide me with an idea to solve this problem (8 Replies)
Discussion started by: maxim42
8 Replies

6. Shell Programming and Scripting

Join the lines

Hi All, Currently, the output looks like this: hdisk0 queue_depth:3 hdisk1 queue_depth:3 hdisk2 queue_depth:1 hdisk3 queue_depth:1 I need to change the format to look like this: hdisk0 queue_depth:3 hdisk1 queue_depth:3 hdisk2 queue_depth:1 (8 Replies)
Discussion started by: Beginer0705
8 Replies

7. Shell Programming and Scripting

join lines

input1 x x input2 y x x z join input1 input2>>output ouput x x (2 Replies)
Discussion started by: repinementer
2 Replies

8. UNIX for Dummies Questions & Answers

how to join lines

can anyone tell me as "how to join all lines in a file " using a shell script Actually i have many files in a directory and for each file i want to join all the lines using a shell scrip . Thanks in advance!!! (8 Replies)
Discussion started by: glamo_2312
8 Replies

9. Shell Programming and Scripting

join (pls help on join command)

Hi, I am a new learner of join command. Some result really make me confused. Please kindly help me. input: file1: LEO oracle engineer 210375 P.Jones Office Runner ID897 L.Clip Personl Chief ID982 S.Round UNIX admin ID6 file2: Dept2C ID897 6 years Dept5Z ID982 1 year Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies

10. Shell Programming and Scripting

join two lines together

Hi, I have a file with on one line a uid, and on the next line a date. I am trying to make the to into one line. Here's an example: koppx 20031125 kraan 20031119 sarox 20031107 And this is what i want it to be: koppx;20031125 kraan;20031119 sarox;20031107 I have been trying... (4 Replies)
Discussion started by: tine
4 Replies
Login or Register to Ask a Question