Complicated Join command!


 
Thread Tools Search this Thread
Operating Systems Linux Complicated Join command!
# 1  
Old 10-14-2009
Complicated Join command!

Hi I have a serious issue when trying to join to files

so I have two files, one for meals and one for people

Meal1:Turkey:Potato Chips:Twinkie:Coke:5.95
Meal2:Ham & CheeseSmilieoritos:Cookie:Sprite:6.49
Meal3:Vegetarian:Cheese Crackers:Brownie:Pepsi:5.75
Meal4:Tuna:Cheese Puffs:EclairSmilieiet Coke:6.95


1234:John:Smith:Meal1:103
2345:Bob:Brown:Meal3:155
3456:Susan:Jones:Meal2:215
4567:Betty:Boop:Meal2:444
5678:Abbie:Normal:Meal3:122
6789:Carla:Carmes:Meal4:212
7890SmilieavidSmilieork:Meal1:355
8901:Joe:Johnson:Meal3:246
9012:Karen:Kook:Meal1:364



what im trying to do is join the two
i've tried

[join -1 4 -2 1 -t: people meals > orders]

but it does not seem to work, can anyone help please Smilie
# 2  
Old 10-15-2009
What you expect it to do ?

What it is not doing ? What error you get ?!

Assuming you had given the order of file wrongly, 1st file 1st field, and 2nd file 4th field, and following works.
Code:
$ join -1 1 -2 4 -t: t1 t2
Meal1:Turkey:Potato Chips:Twinkie:Coke:5.95:1234:John:Smith:103
Meal3:Vegetarian:Cheese Crackers:Brownie:Pepsi:5.75:2345:Bob:Brown:155
Meal4:Tuna:Cheese Puffs:Eclairiet Coke:6.95:6789:Carla:Carmes:212

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Join Command

Hi, Please explain the working process of join command. File 1 P B S A C AFile2 C B P A S DBut the output of join command is... join File1.txt File2.txt P B A S A DBut I guess the output should be P B A S A D C A BPlease correct me,if i am worong or missing some thing. Thanks (2 Replies)
Discussion started by: satyar
2 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

complicated exclude option in find command

Hi all, In a directory, I have many video files. Example : As you can see, some of the video files come with a .aspx file (wich means the video is actually being uploaded and not entirely written on the FS) I try to write a bash script that would find all video files in the ... (1 Reply)
Discussion started by: gniagnia
1 Replies

5. Shell Programming and Scripting

complicated alias command

hi guys i m making one alias which will set variable , invoke sqlplus and also set prompt of sqlplus,,i have made successfully upto invoking sqlplus in unix but cant pass command in sqlplus here is the command alias sett='export ORACLE_SID=devdb2;sqlplus system/system@test' now this... (3 Replies)
Discussion started by: tapia
3 Replies

6. Shell Programming and Scripting

awk command for simple join command but based on 2 columns

input1 a_a a/a 10 100 a1 a_a 20 200 b1 b_b 30 300 input2 a_a a/a xxx yyy a1 a1 lll ppp b1 b_b kkk ooo output a_a a/a 10 100 xxx yyy (2 Replies)
Discussion started by: ruby_sgp
2 Replies

7. Shell Programming and Scripting

Bash alias for complicated ls command does not work.

I'm trying to set up an alias in .bash_aliases to show just the filenames of the files in a directory, which the following command will do: ls -l | grep ^- | awk '{print $NF}' kjb.zip ap.zip tor.zip However when I set up the following alias in .bash_aliases: alias lf="ls -l | grep ^- |... (16 Replies)
Discussion started by: gencon
16 Replies

8. 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

9. Shell Programming and Scripting

Join Command Help

Hi, I am trying to use join command for two files of size greater than 1 GB. join -t , -1 2 -2 1 -o 1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19,1.20,1.21,1.22,1.23 File1 File2 > File3 we are facing space crunch after using these join command. May i... (0 Replies)
Discussion started by: jerome Sukumar
0 Replies

10. Shell Programming and Scripting

Using Join Command

Greetings, I am attempting to use the join command to produce a file from 2 sorted comma seperated files. Ex.: FILE 1: jane,dow joe,blow FILE 2: jane,dow,50,50,20 joe,blow,29,53,25 spike,lee,50,91,05 I want the resulting file to be reconds in FILE 2 where the person exists in FILE... (4 Replies)
Discussion started by: Supial
4 Replies
Login or Register to Ask a Question