title: AWK: print colums of a matrix using first column as reference
body: <p>I want to read first colum in a matrix, and then print columns of this matrix using this first colum as reference. And example:</p>
  
  <pre><code>mat.txt
  2 10 6 12 3
  4 11 1 22 6
  5 15 3 18 9</code></pre>
  
  <p>Using first column as reference, I would like to get columns 2, 4 and 5, and also put the value of first colum at the begining. </p>
  
  <pre><code>2 10 12 3
  4 11 22 6
  5 15 18 9</code></pre>
  
  <p>I try this, but doesn't work well:</p>
  
  <pre><code>awk 'FNR==NR{c++;cols[c]=$1;end}
              {for(i=1;i&lt=c;i++) printf("%s%s",$(cols[i]+1),i&ltc ? OFS : "\n")}' mat.txt mat.txt
  </code></pre>