title: Code editing using bash script and test processing
body: <p>I have a file that defines many methods with headers of the form</p>
  
  <pre><code>void Method1(double arg1[M][N], double arg2[M][N], ...)
  {
  }
  </code></pre>
  
  <p>I would like to use a bash script to replace the arguments <code>"double arg1[M][N]"</code> and <code>"double arg2[M][N]"</code> with <code>"const vector&lt;vector&lt;double&gt;&gt;&amp; arg1"</code> and <code>"vector&lt;vector&lt;double&gt;&gt;&amp; arg2"</code>, respectively, so that the 
  function header reads as</p>
  
  <pre><code>void Method1(const vector&lt;vector&lt;double&gt;&gt;&amp; arg1, const vector&lt;vector&lt;double&gt;&gt;&amp; arg2, ...)
  {
  }
  </code></pre>
  
  <p>How can I implement this using awk or sed? So far I have tried calling <code>sed</code> twice on the file like this</p>
  
  <pre><code>sed -i "s/double/const vector\&lt;vector\&lt;double\&gt;\&gt;\&amp;/g" file.cpp
  </code></pre>
  
  <p>followed by</p>
  
  <pre><code>sed -i "s/\[M\]\[N\]//g" file.cpp
  </code></pre>
  
  <p>but the first call to sed matches anything with the pattern "double" in it, including methods with only scalar arguments of type <code>double</code>, which must remain untouched.</p>