title: sed match pattern and substitute in html
body: <p>I want to substitute text in-between only specific html tag, example html file</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  original text
  &lt;title&gt;original text&lt;/title&gt;
  original text
  &lt;head&gt;
  &lt;body&gt;
  original text
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here I want to replace text "original" by "modified" only in-between the tag "title" I tried the following but that replaces everywhere except before title tag. I do need to keep global "g".</p>
  
  <pre><code> sed -i '' '/&lt;title&gt;/,/&lt;\/title&gt;/ s/original/modified/g' test.html
  </code></pre>
  
  <p>Also, I don't understand why do I need ''(two single quote) in my script, for example this one works well (with double quotes)</p>
  
  <pre><code> sed -i -e "s/original/modified/g" test.html
  </code></pre>
  
  <p>if I have match pattern then the below one doesn't work</p>
  
  <pre><code> sed -i -e "/first/,/last/ s/original/modified/g" test.html
  </code></pre>
  
  <p>and I need to have '' to get it work as below</p>
  
  <pre><code>  sed -i '' '/first/,/last/ s/original/modified/' test.html
  </code></pre>
  
  <p>I am using Mac OSX 10.9, also not sure of a better way to do this. thanks</p>