Re: sed help
Originally Posted by
mobilediesel
This works, too, and shortens the command a bit:
Code:
sed 's/\(<caption>\)[^<]*\(<\/caption>\)/\1\2/g' file.xml >file2.xml
Using
[^<]* will match any character up to the
</caption> tag. Putting
<caption> and
<\/caption> inside
( and
) means you only need
\1\2 in the replacement end.
one thing worth noting is that the command separator for sed doesn't have to be a '/', so you could instead write it like this:
Code:
sed 's:\(<caption\)[^<]*\(</caption>\):\1\2:g' file.xml > file2.xml
which is a bit more legible
there are 10 types of people in the world: those that understand binary and i don't know who the other F are.
Bookmarks