You can specify two regular expressions as the range. Assuming a "#"
starts a comment, you can search for a keyword, remove all comments
until you see the second keyword. In this case the two keywords are
"start" and "stop:" 


sed '/start/,/stop/ s/#.*//'


The first pattern turns on a flag that tells sed to perform the
substitute command on every line. The second pattern turns off the flag.
If the "start" and "stop" pattern occurs twice, the substitution is done
both times. If the "stop" pattern is missing, the flag is never turned
off, and the substitution will be performed on every line until the end
of the file.

You should know that if the "start" pattern is found, the substitution
occurs on the same line that contains "start." This turns on a switch,
which is line oriented. That is, the next line is read and the
substitute command is checked. If it contains "stop" the switch is
turned off. Switches are line oriented, and not word oriented.

ie. algo del estilo

sed '/<b>/,/<\/b>/ s/\(Titulo: \).*/\1OTRO ALGO<\/b>/'

debería andar

saludos

El mié, 15-07-2009 a las 18:09 -0300, personaje escribió:

> Hola lista,
> 
>     Tengo que hacerme un script para reemplazar el texto encontrado
> entre dos matcheos regexp. Por ejemplo: tengo un .html en el que
> quiero reemplazar [algo], siempre que se encuentre encerrado entre:
> <b>Titulo: [algo] </b>
> 
> Gracias.
> 
> _______________________________________________
> Lista de correo Programacion.
> [email protected]
> http://listas.fi.uba.ar/mailman/listinfo/programacion
_______________________________________________
Lista de correo Programacion.
[email protected]
http://listas.fi.uba.ar/mailman/listinfo/programacion

Responder a