title: Find and replace using xargs sed - can I save the results to a file?
body: <p>My code to replace all instances of 'foo' with 'bar' :</p>
  
  <pre><code>find . -type f |
  xargs grep 'foo' -l |
  xargs sed -i 's|foo|bar|g'
  </code></pre>
  
  <p>I'd like to save a list of the modified files to a text document. Is it possible? </p>
  
  <p>EDIT :</p>
  
  <p>This is the final code that worked for me :</p>
  
  <pre><code>find . -type f -print0 |
  xargs -0 grep 'foo' -l |
  tee result.txt |
  xargs -0 sed -i 's|foo|bar|g'
  </code></pre>
  
  <p>Not sure whether this is the quickest way, but for a few thousand files the difference in speed between this and other suggested methods is probably very small.</p>