title: Using sed to replace beginning of line when match found
body: <p>I have a Java file. I want to comment any line of code that contains the match:</p>
  
  <pre><code> myvar
  </code></pre>
  
  <p>I think sed should help me out here</p>
  
  <pre><code> sed 's/myVar/not_sure_what_to_put_here/g' MyFile.java
  </code></pre>
  
  <p>I don't know what to put in:</p>
  
  <pre><code>not_sure_what_to_put_here
  </code></pre>
  
  <p>as in this case, I don't want to replace myVar but the I want to insert </p>
  
  <pre><code>//
  </code></pre>
  
  <p>to the beginning of any line myVar occurs on.</p>
  
  <p>Any tips</p>