Join help with -e option


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Join help with -e option
# 1  
Old 08-21-2006
Data Join help with -e option

I am trying to use join with the -e option to join columns in two files, with the -e option to replace empty fields with periods. I use the command:
Code:
join -e "." -a1 -a2 a.txt b.txt

But the -e option does not seem to work, because no periods appear (nor x's if I use -e "x" instead) when blank cells result. Am I doing something wrong? (I am using Mac OS X's Terminal.)

Here is a transcript:
Code:
$ cat a.txt
1 "a bc" 5
2 "asbdfghjksdlhwugyhe" 4
3 "as ds wd sdw swdw wd" 5
8 "french" 3
$ cat b.txt
1 "abc" 3
2 "def" 2
3 "gh i" 1
4 "fred"
$ join -e "." -a1 -a2 a.txt b.txt
1 "a bc" 5 "abc" 3
2 "asbdfghjksdlhwugyhe" 4 "def" 2
3 "as ds wd sdw swdw wd" 5 "gh i" 1
4 "fred"
8 "french" 3

The -e option to joing seemingly should yield .'s in the output lines beginning 4 and 8, but did not. Apologies if I am missing the obvious -- I've tried all the man pages, web pages, etc. I can think of and haven't figured this one out. (I am preparing to do this on circa 500MB sorted files.)

Any suggestions will be much appreciated!!!
# 2  
Old 08-21-2006
I think the -e option is only to be used with the -o option, e.g...
Code:
$ join -e "." -a1 -a2 -o '0 1.2 1.3 2.2 2.3' a.txt b.txt
1 "a bc" "abc" 3
2 "asbdfghjksdlhwugyhe" 4 "def" 2
3 "as ds "gh i"
4 . . "fred" .
8 "french" 3 . .

...which is probably not what you want.
# 3  
Old 08-21-2006
Bug Problem solved

Thanks Ygor, That was just what I was missing; -e requires -o. The -o option requires knowing the number of fields in files a.txt and b.txt, which ideally one need not know (join could count them), but since I know these numbers the -o solution works fine for me. Thanks again.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join, merge, fill NULL the void columns of multiples files like sql "LEFT JOIN" by using awk

Hello, This post is already here but want to do this with another way Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: 1|123|jojo 1|NULL|bibi... (2 Replies)
Discussion started by: yjacknewton
2 Replies

2. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

3. UNIX for Dummies Questions & Answers

Join?

Hi, I am trying to exclude certain rows in File 1, based on File 2. i.e. in the example below, File 3 should be the output; i.e. the rows in File 2 are excluded from File 1. Any hints/suggestions would be highly appreciated. Input File 1: a 1 xxx b 1 wje c 5 ere c 2 qqq d 3 yyy ... (9 Replies)
Discussion started by: pc2001
9 Replies

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

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

6. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

7. UNIX for Dummies Questions & Answers

Join 2 files with multiple columns: awk/grep/join?

Hello, My apologies if this has been posted elsewhere, I have had a look at several threads but I am still confused how to use these functions. I have two files, each with 5 columns: File A: (tab-delimited) PDB CHAIN Start End Fragment 1avq A 171 176 awyfan 1avq A 172 177 wyfany 1c7k A 2 7... (3 Replies)
Discussion started by: InfoSeeker
3 Replies

8. Programming

sql,multiple join,outer join issue

example sql: select a.a1,b.b1,c.c1,d.d1,e.e1 from a left outer join b on a.x=b.x left outer join c on b.y=c.y left outer join d on d.z=a.z inner join a.t=e.t I know how single outer or inner join works in sql. But I don't really understand when there are multiple of them. can... (0 Replies)
Discussion started by: robbiezr
0 Replies

9. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

10. 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
Login or Register to Ask a Question