Replace text block in multiple files

I need to replace (delete) a text block in a bunch of files, its a html table, almost at the end of pages but the location varies.

In Windows I used Filemonkey, but nothing like that in Unix?

There is replace from mysql, but how does it deal with newlines?

sed only works with single lines, tr on single characters...

Isn't there an utility that takes a textblock from an input file and replaces that block in target files?

why dont you paste a sample i/p and the expected o/p. We should be able to go from there to help you.

cheers,
Devaraj Takhellambam

from

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html LANG="ES"> 
<head> 
<body>
 a lot of varying html 
<hr> 
<table border="0" cellpadding="0" cellspacing="0" align="right" summary="just a navigational helper"> 
<tr>a few lines of not changing table cells and rows 
</tr> 
</table>

</body> 
</html> 

into

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html LANG="ES"> 
<head> 
<body>
a lot of varying html
</body> 
</html> 
sed -e '/\<table/,/^$/d' file

cheers,
Devaraj Takhellambam

Hello, try with this:

write="1"
while read linea
do
    if [ "$linea_ant" = "<hr>" ] && [ "$linea" = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"right\" summary=\"just a navigational helper\">" ]
    then
        write="0"
    else
        if [ "$linea_ant" = "</table>" ]
        then
            write="-1"
        fi
    fi
    if [ "$write" = "1" ]
    then
        echo $linea_ant
    fi
    if [ "$write" = "-1" ]
    then
        write="1"
    fi
    linea_ant="$linea"

done < html1

if [ "$write" = "1" ]
then
    echo $linea_ant
fi

is not very 'general' but you can modify it if you have "spaces" at the beginning of the line. Mind if there is another table inside the table you want to drop this basic script doesn't run...

This example deletes the lines between "<hr>" untill the line before the next "</body>":

awk '
/<hr>/{p=1}		# Set variable p
/<\/body>/{p=0}		# Reset variable p
!p' file		# Print lines if variable p is NOT set

thanks for the posts - just to remind you that the html block contains a lot of html, tables, lines, etc. so all suggestions deleting "after tr" or deleting just a table are not productive

And the table I want to delete slightly alters now and then. Now I don't mind changing the table input here and there, but unescaping all characters, lines etc, is a bit too complicated if you have to do it thirty times. Thats why I asked about an input file....