title: sed - Include newline in pattern
body: <p>I am still a noob to shell scripts but am trying hard. Below, is a partially working shell script which is supposed to remove all JS from *.htm documents by matching  tags and deleting their enclosed content. E.g. <code>&lt;script src=""&gt;</code>, <code>&lt;script&gt;&lt;/script&gt;</code> and <code>&lt;script type="text/javascript"&gt;</code> </p>
  
  <pre><code>find $1 -name "*.htm" &gt; ./patterns
  for p in $(cat ./patterns)
  do
  sed -e "s/&lt;script.*[.&gt;]//g" $p #&gt; tmp.htm ; mv tmp.htm $p
  done
  </code></pre>
  
  <p>The problem with this is script is that because sed reads text input line-by-line, this script will not work as expected with new-lines. Running:</p>
  
  <pre><code>&lt;script&gt;
  //Foo
  &lt;/script&gt;
  </code></pre>
  
  <p>will remove the first script tag but will omit the "foo" and closing  tag which I don't want. </p>
  
  <p>Is there a way to match new-line characters in my regular expression? Or if <code>sed</code> is not appropriate, is there anything else I can use?</p>