title: Using sed to replace pattern
body: <p>How can i write bash script to do the below</p>
  
  <ol>
  <li>search all files recursively within directory ending with html and htm.</li>
  <li>using sed to search for <code>&lt;body&gt;</code> and delete all lines before this line including the <code>&lt;body&gt;</code> line</li>
  <li>As well as searching for <code>&lt;/body&gt;</code> and deleting all the lines after that including <code>&lt;body&gt;</code> line.</li>
  <li>the change should not be on the same file but like index-temp.html.</li>
  </ol>
  
  <p>I wrote the below but I cant get how can I change the whole block after and safe the change to another file and not on the same file. Do I have to use if?</p>
  
  <pre><code>#!/bin/bash
  input=$1
  find "$input" -type f -name "*.htm" -exec sed 
  </code></pre>