$> sed -i"" '8,40{/<table/,/<\/table/d;}" *.html
#delete in the diapasone all lines between the first and the second paterns

#delete the line containing the pattern 'Unix' and also the next line:
  $> sed '/Unix/{N;d;}' file

#delete only the next line containing the pattern 'Unix', not the very line:
  $> sed '/Unix/{N;s/\n.*//;}' file

#substitution command s where the flags that modify the substitution are:
n     a number (1 to 512) indicating that a replacement should be made
      for only the nth occurrence of the pattern.

# reduce multiple blank lines to one
   sed '/^$/N;/^\n$/d;' <file>

 |  h or H   copy or append contents of pattern space to hold space   |
 |  g or G   copy or append contents of hold space to pattern space   |
 |  x        swap contents of hold space and pattern space            |

d      delete pattern space. start next cycle.

D      if pattern space contains no newline, start a normal new cycle 
       otherwise, delete  text  in  the  pattern space up to the first newline, and
       restart cycle with the resultant pattern space, without reading a new line of input

# change the second and the third lines:
    sed '2h;2d;3G' <file>

a          appends after the line the text you provide
i          inserts before the line the text you provide
c          replaces the contents of the pattern space with the text you provide. 

n N        read/append the next line of input into the pattern space

t label    if a s/// has done a successful substitution since the last input line was read
           then branch to label; if label is omitted, branch to end of script

w file     write the current pattern space to 'file'