3

I am joining two very simple sorted files but for some strange reason it is not working. f1.txt:

f1 abc
f2 mno
f3 pqr

f2.txt:

abc a1
mno a2
pqr a3

Command:

join -t '\t' f1.txt f2.txt -1 2 -2 1 > f3.txt

FYI in the f1,f2 files the space is a tab. But this is producing a blank f3.txt. Why is this happening? This is such a simple example of joining right?

1 Answers1

2

Your \t isn't being interpreted as a tab character. To do that you could/should use an ANSI string so your command would become

join -t $'\t' f1.txt f2.txt -1 2 -2 1 > f3.txt

with the $ before the '\t' so it will be interpreted as a tab like you want.

A handy resource for quoting things with bash at least is available here

Eric Renouf
  • 1,894