title: Bash: join by numeric column
body: <p>If I want to use <code>join</code> on my Ubuntu, I need to first sort both files lexicographically (according to <code>join --help</code>), and only then join them:</p>
  
  <pre><code>tail -n +2 meta/201508_1 | sort -k 1b,1 &gt; meta.txt
  tail -n +2 keywords/copy | sort -k 1b,1 &gt; keywords.txt
  join meta.txt keywords.txt -1 1 -2 1 -t $'\t' 
  </code></pre>
  
  <p>(I also remove the header from both of them using <code>tail</code>)</p>
  
  <p>But instead of sorting files lexicographically, I would like to sort them numerically: the first column in both files is an ID. </p>
  
  <pre><code>tail -n +2 meta/201508_1 | sort -k1 -n &gt; meta.txt
  tail -n +2 keywords/copy.txt | sort -k1 -n &gt; keywords.txt
  </code></pre>
  
  <p>And then join. But for <code>join</code> these files look unsorted:</p>
  
  <pre><code>join: meta.txt:10: is not sorted: 1023  301000  en
  join: keywords.txt:2: is not sorted: 10 keyword1
  </code></pre>
  
  <p>If I add <code>--nocheck-order</code> to <code>join</code>, it doesn't join properly - it outputs just one line. </p>
  
  <p>How do I join two files on their numerical ID in bash?</p>
  
  <p>Sample (columns are tab-separated):</p>
  
  <p>file 1</p>
  
  <pre><code>id  volume lang
  1   10  en
  2   20  en
  5   30  en
  6   40  en
  10  50  en
  </code></pre>
  
  <p>file 2</p>
  
  <pre><code>id  keyword
  4   kw1
  2   kw2
  10  kw3
  1   kw4
  3   kw5
  </code></pre>
  
  <p>desired output </p>
  
  <pre><code>1   kw4 10  en
  2   kw2 20  en
  10  kw3 50  en
  </code></pre>