text: user4783: File1:
  ENST00000000233 ARF5
  ENST00000000412 M6PR
  ENST00000001008 FKBP4
  ENST00000001146 CYP26B1
  ENST00000002501 DBNDD1
  ENST00000002596 HS3ST1
  
  File 2:
  ENST00000000412 0.779142
  ENST00000001008 0.738143
  ENST00000002501 0.715315
  ENST00000002596 0.713664
  
  Desired Output
  ENST00000000412 0.779142    M6PR
  ENST00000001008 0.738143    FKBP4
  ENST00000002501 0.715315    DBNDD1
  ENST00000002596 0.713664    HS3ST1
  
  
  user4001: Using awk, this can be done in the following way:
  awk 'NR==FNR{a[$1]=$2; next}$1 in a{print $1, $2, a[$1]}' file1.txt file2.txt > same.txt
  
  Explanation:
  NR==FNR (along with the next command) 
  
  Will go through the first file only and create an associative array of of the geneIDs corresponding with the geneNames. 
  Then if the 1st column in the 2nd file is present in the array, a, it will print both columns from the file plus the geneName.
  
  user92: I like to use the join command for this. For your example above, you can simply use the following:
  $ join file2 file1
  ENST00000000412 0.779142 M6PR
  ENST00000001008 0.738143 FKBP4
  ENST00000002501 0.715315 DBNDD1
  ENST00000002596 0.713664 HS3ST1
  
  This assumes your files are sorted. If they aren't sorted, you can use input redirection if your shell supports it (bash and other modern shells do):
  join <(sort -k 1b,1 file2) <(sort -k 1b,1 file1)
  
  If your shell doesn't support <(), sort the files first:
  sort file1 > file1.sorted; sort file2 > file2.sorted
  join <(sort -k 1b,1 file2.sorted) <(sort -k 1b,1 file1.sorted)
  
  
original_text: 4783: <p>File1:</p>
  
  <pre><code>ENST00000000233 ARF5
  ENST00000000412 M6PR
  ENST00000001008 FKBP4
  ENST00000001146 CYP26B1
  ENST00000002501 DBNDD1
  ENST00000002596 HS3ST1
  </code></pre>
  
  <p>File 2:</p>
  
  <pre><code>ENST00000000412 0.779142
  ENST00000001008 0.738143
  ENST00000002501 0.715315
  ENST00000002596 0.713664
  </code></pre>
  
  <p>Desired Output</p>
  
  <pre><code>ENST00000000412 0.779142    M6PR
  ENST00000001008 0.738143    FKBP4
  ENST00000002501 0.715315    DBNDD1
  ENST00000002596 0.713664    HS3ST1
  </code></pre>
   4001: <p>Using awk, this can be done in the following way:</p>
  
  <pre><code>awk 'NR==FNR{a[<span class="math-container">$1]=$</span>2; next}<span class="math-container">$1 in a{print $1, $2, a[$</span>1]}' file1.txt file2.txt &gt; same.txt
  </code></pre>
  
  <p>Explanation:</p>
  
  <pre><code>NR==FNR (along with the next command) 
  </code></pre>
  
  <p>Will go through the first file only and create an associative array of of the geneIDs corresponding with the geneNames. </p>
  
  <p>Then if the 1st column in the 2nd file is present in the array, a, it will print both columns from the file plus the geneName.</p>
   92: <p>I like to use the <code>join</code> command for this. For your example above, you can simply use the following:</p>
  
  <pre><code>$ join file2 file1
  ENST00000000412 0.779142 M6PR
  ENST00000001008 0.738143 FKBP4
  ENST00000002501 0.715315 DBNDD1
  ENST00000002596 0.713664 HS3ST1
  </code></pre>
  
  <p>This assumes your files are sorted. If they aren't sorted, you can use input redirection if your shell supports it (bash and other modern shells do):</p>
  
  <pre><code>join &lt;(sort -k 1b,1 file2) &lt;(sort -k 1b,1 file1)
  </code></pre>
  
  <p>If your shell doesn't support <code>&lt;()</code>, sort the files first:</p>
  
  <pre><code>sort file1 &gt; file1.sorted; sort file2 &gt; file2.sorted
  join &lt;(sort -k 1b,1 file2.sorted) &lt;(sort -k 1b,1 file1.sorted)
  </code></pre>
  