title: bash/sed/awk: replace arbitrary substring in arbitrary files
body: <p><strong>Update:</strong></p>
  <p>I have tried markp-fuso's answer and it worked like a charm</p>
  <p>I'm starting to get frustrated here as I'm not a daily user of bash/sed and the like.</p>
  <p><strong>Starting point:</strong></p>
  <p>I have many subfolders with many source files (<code>.c,.cpp,.cxx</code>).
  These source files are referenced for compilation in project files (<code>.vcxproj</code>).</p>
  <p><strong>What I want to do:</strong></p>
  <p>I want to find all source files that contain the string <code>#import</code>. I then want to find all project files that reference those source files.
  I then want to edit all occurences of these references inplace within these project files
  e.g. <code>&lt;Include=&quot;folder/file.cpp&quot;/&gt;</code> -&gt; <code>&lt;Include=&quot;folder/file.cpp&quot; Attribute=&quot;Value&quot;/&gt;</code></p>
  <p><strong>What I have tried:</strong></p>
  <pre><code>egrep -lir --include=*.{c,cpp,cxx} &quot;(#import)&quot; ./e3 | xargs -L 1 basename | egrep -ir --include=*.vcxproj -f - ./e3 | sed 's/:/ /g'
  </code></pre>
  <p>which produces a list like that:</p>
  <pre><code>./src/base/base.vcxproj     &lt;ClCompile Include=&quot;Folder1\Folder1File1.cpp&quot; /&gt;
  ./src/mod/mod.vcxproj     &lt;ClCompile Include=&quot;Folder2\Folder2File1.cpp&quot; /&gt;
  ./src/ext/ext.vcxproj     &lt;ClCompile Include=&quot;Folder3\Folder3File1.cpp&quot; /&gt;
  </code></pre>
  <p>So I then tried</p>
  <pre><code>egrep -lir --include=*.{c,cpp,cxx} &quot;(#import)&quot; ./e3 | xargs -L 1 basename | egrep -ir --include=*.vcxproj -f - ./e3 | sed 's/:/ /g' | awk '{ sed -iE 's/($2,$3)/\1 Attribute=&quot;Value&quot;/g' }'
  </code></pre>
  <p>which errors out with</p>
  <pre><code>bash: syntax error near unexpected token `('
  </code></pre>
  <p>I have tried a solution with a shell script, which didn't work either and I don't know if and how to solve above error message. I'm open to any solution as long as it's running within bash, can even be more gross than what I came up with.</p>