title: Replacing a field in text file with the result of a system command
body: <p>Using Bash commands, I would like to substitute field 3 of each line of a text file with the result of a command which takes the original field 3 as an argument. Fields are <code>/</code>-delimited.</p>
  
  <p>Input file:</p>
  
  <pre><code>./REMOTE_PARENT_DIR/0x134000564f:0x4c:0x0/test_runs/testgsi_O1
  ./REMOTE_PARENT_DIR/0x134000564f:0x4c:0x0/test_runs/testgsi_O2
  ...
  </code></pre>
  
  <p>Desired output file (don't print field 1 and 2, field 3 will be result of Unix  command, print remaining fields):</p>
  
  <pre><code>/scratch/000011/rin/test_runs/testgsi_O1
  /scratch/000011/rin/test_runs/testgsi_O2
  ...
  </code></pre>
  
  <p>Command to translate field 3 into normal path components:</p>
  
  <pre><code>hostx#lfs fid2path /scratch [0x134000564f:0x4c:0x0]
  /scratch/000011/rin
  </code></pre>
  
  <p>Maybe use <code>awk</code> to grab the relevant field then <code>sed</code> with command substitution then spit out the new line?</p>
  
  <p>This prints out the bit I need but not sure how to substitute into the lines of the file:</p>
  
  <pre><code>awk -F "/" '{ system("/bin/lfs fid2path /scratch " $3) }' outfile.70.sample.tmp
  </code></pre>