In the comments of an answer started a discussion related to using GNU coreutils' join
for creating cartesian product of two files. A fellow user suggested that:
$ join -j 2 -t '' file1 file2
produces cartesian product of file1
and file2
:
$ cat file1
1
2
$ cat file2
a
b
Expected output:
$ join -j 2 -t '' file1 file2
1a
1b
2a
2b
Well, I'm getting:
$ join -t '' -j 2 file1 file2
1
a
1
b
2
a
2
b
I've tested in 2 Debian Jessies (join
(GNU coreutils) 8.23) and a Ubuntu Trusty Tahr (join
(GNU coreutils) 8.21) with C and en_US.utf8 locales (all systems installed and administered by different parties). Reportedly join
behaves as expected in OS X and a system with join
(GNU coreutils) 8.22.
Has anyone ran into this before? What am I doing wrong?
you need use as delimiter '\0'
join -t '\0' -j 2 file1 file2