I am trying to use the standard command-line tool join
to join two files. According to the documentation, both input files need to be sorted for this. Initially I just piped them through sort
to achieve this, but this still resulted in errors like "join: file 2 is not in sorted order". I then looked into this a bit more closely and found that I was supposed to use sort -k 1b,1
, but that didn't seem to help either. I even played around with the locales (setting LANG=C
or LANG=EN_en
) but nothing seems to work.
So far I tried:
cat x | sort | join -j 1 a -
cat x | sort -k1b,1 | join -j 1 a -
cat x | LANG=C sort -k1b,1 | join -j 1 a -
cat x | LANG=EN_en sort -k1b,1 | join -j 1 a -
So, how do I use join correctly on unsorted files?
Basically :