tags:

views:

280

answers:

3

Sorry for the maybe trivial question.

I fought a bit with the unix join command, trying to get tabs instead of whitespaces as the default separators. -t is the argument, but these don't work (ubuntu 9.10 64 bit 2.6.31-14, GNU coreutils version 7.4)

join file1 file2 -t"\t"
join file1 file2 -t="\t"
join file1 file2 -t="\\t"
join file1 file2 -t $"\t"

Et cetera. Of course, I can always use some inelegant solution like

join file1 file2 > output
sed "s/ /\t/g" output

But I wanted to look smart :-) Moreover, if there's a -t argument, it must work.

+2  A: 

man join says, that the options have to come in front of the filenames. Have you tried

join -t "\t" file1 file2

?

Edit: Reflecting Tonio's answer, the correct line would read

join -t $'\t' file1 file2
Boldewyn
Yep, doesn't work.It gives the error:join: multi-character tab `\\t'
Thrawn
Remove the quotes? At least the error message disappears on my terminal.
Boldewyn
I agree, error disappears, but the output is wrongly empty like this :-/
Thrawn
OK, it's no good having both no error messages and no output...
Boldewyn
+4  A: 

I think it takes a variable generated on-the-fly

Try

join file1 file12 -t $'\t'
Tonio
genius. it works!
Thrawn
Cool. I didn't know the `$'...'` syntax before.
Boldewyn
A: 
join -t "`echo '\t'`" file1 file2

ps: on my machine, Red Hat Enterprise Linux Server release 5.1 (Tikanga), the command join -t $'\t' file1 file2 returns "Illegal variable name".

tim