title: Replace a column in a file but maintain the space format
body: <p>I have a code below that replaces the 4th column in fileA based on the data in fileB but the output didn't maintain the spaces of the original file. Is there anyway to do it?</p>
  
  <pre><code> tr , " " &lt;fileB | awk 'NR==FNR{a[$2]=$1;next} {$4=a[$4];print}' - fileA
  </code></pre>
  
  <p>fileA</p>
  
  <pre><code> xxx    xxx   xxx Z0002
  </code></pre>
  
  <p>fileB</p>
  
  <pre><code> 3100,3000
   W0002,Z0002
  </code></pre>
  
  <p>output using the code above:</p>
  
  <pre><code> xxx xxx xxx W0002
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code>xxx    xxx   xxx W0002
  </code></pre>