title: How to use sed to replace a string within a string?
body: <p>I read the following article "<a href="https://stackoverflow.com/questions/6178498/using-grep-and-sed-to-find-and-replace-a-string">Using grep and sed to find and replace a string</a>" but how can I extend it to chain multiple greps. For example I have the following directory/file structure</p>
  
  <pre><code>dir1/metadata.txt
  dir2/metadata.txt
  </code></pre>
  
  <p>dir1/metadata.txt has</p>
  
  <pre><code>filename1 '= 1.0.0'
  filename2 '= 1.0.0'
  </code></pre>
  
  <p>dir2/metadata.txt has</p>
  
  <pre><code>filename1     '= 1.0.0'
  long_filename '= 1.0.0'
  </code></pre>
  
  <p>In other words, both dir1/metadata.txt and dir2/metadata.txt contain "filename '1.0.0'" but the spaces between the "filename" and the "'1.0.0'" in each file is different.</p>
  
  <p>Now I want to replace filename1's associated version to '2.0.0' in ALL metadata.txt files so the resulting files look like...</p>
  
  <p>dir1/metadata.txt has</p>
  
  <pre><code>filename1 '= 2.0.0'
  filename2 '= 1.0.0'
  </code></pre>
  
  <p>dir2/metadata.txt has</p>
  
  <pre><code>filename1     '= 2.0.0'
  long_filename '= 1.0.0'
  </code></pre>
  
  <p>I'm trying</p>
  
  <pre><code>find . -name metadata.txt | xargs grep filename1 | sed -i "s/1\.0\.0/2.0.0/g" &lt;some option here&gt;
  </code></pre>
  
  <p>but I know the "some option here" part. Any clues?</p>