title: Unix join on more than two files
body: <p>I have three files, each with an ID and a value. </p>
  
  <pre><code>sdt5z@fir-s:~/test$ ls
  a.txt  b.txt  c.txt
  sdt5z@fir-s:~/test$ cat a.txt 
  id1 1
  id2 2
  id3 3
  sdt5z@fir-s:~/test$ cat b.txt 
  id1 4
  id2 5
  id3 6
  sdt5z@fir-s:~/test$ cat c.txt 
  id1 7
  id2 8
  id3 9
  </code></pre>
  
  <p>I want to create a file that looks like this...</p>
  
  <pre><code>id1 1 4 7
  id2 2 5 8
  id3 3 6 9
  </code></pre>
  
  <p>...preferably using a single command.</p>
  
  <p>I'm aware of the join and paste commands. Paste will duplicate the id column each time:</p>
  
  <pre><code>sdt5z@fir-s:~/test$ paste a.txt b.txt c.txt 
  id1 1   id1 4   id1 7
  id2 2   id2 5   id2 8
  id3 3   id3 6   id3 9
  </code></pre>
  
  <p>Join works well, but for only two files at a time:</p>
  
  <pre><code>sdt5z@fir-s:~/test$ join a.txt b.txt 
  id1 1 4
  id2 2 5
  id3 3 6
  sdt5z@fir-s:~/test$ join a.txt b.txt c.txt 
  join: extra operand `c.txt'
  Try `join --help' for more information.
  </code></pre>
  
  <p>I'm also aware that paste can take STDIN as one of the arguments by using "-". E.g., I can replicate the join command using:</p>
  
  <pre><code>sdt5z@fir-s:~/test$ cut -f2 b.txt | paste a.txt -
  id1 1   4
  id2 2   5
  id3 3   6
  </code></pre>
  
  <p>But I'm still not sure how to modify this to accomodate three files. </p>
  
  <p>Since I'm doing this inside a perl script, I know I can do something like putting this inside a foreach loop, something like join file1 file2 > tmp1, join tmp1 file3 > tmp2, etc. But this gets messy, and I would like to do this with a one-liner.</p>