title: commenting out lines with matching string
body: <p>Looking for a simple shell script (with sed or awk) to comment out lines of a text file if a string exists in the line(s). As an example, a text file with the following:</p>
  
  <pre><code>line1 word1 word2
  line2 word3 word4
  line3 word5 word6
  line4 word1 word7
  line5 word10 word11
  </code></pre>
  
  <p>To be changed to:</p>
  
  <pre><code>#line1 word1 word2
  line2 word3 word4
  line3 word5 word6
  #line4 word1 word7
  line5 word10 word11
  </code></pre>
  
  <p>As you see, only the lines with the string "word1" are commented out.</p>