| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Thank you, Ronaldo, for your help in this small matter.
I've been struggling with just how to expand my usage of sed beyond the
rudimentary s/a/b/ type implementation; and this was a great excuse for
a question ;)
Syntax formation seems to be the biggest obstacle for me with regard to
sed. Thank you again for the working snippet to work through & learn
from...
Cheers!
-Marcus
On 10/04/2014 06:13 PM, Ronaldo Ferreira de Lima [email protected]
[sed-users] wrote:
>
> Greetings Marcus,
>
> On Fri, Oct 03, 2014 at 08:44:36PM -0400, 'Marcus L. Thompson'
> [email protected] wrote:
> > Greetings to all.
> >
> > I have come across what seems to be a quite simple problem involving an
> > application of sed in the context of text-block deletion. Here's the
> > hypothetical text block in question:
> >
> > <property name="name">
> > ...
> > </property>
> > </property>
> >
> > Now, deleting all from <property name="name"> to the _/first/_
> > </property> tag is understandable enough:
> >
> > Code:
> >
> > sed -i '/<property name="name">*$/,/<\/property>*$/d' /file.xml
> >
> > However, incorporating the 2nd </property> tag in the deletion sweep is
> > a bit tougher; and just that much outside my new skillset range ;o)
> >
> > Any ideas as to how one might amend this "one-liner" to make it all
> work?
> You might try:
>
> $ sed '/<property
> name="name">/{:loop;/<\/property>.*<\/property>/{s/.*//;b;};N;b
> loop;};' file.xml
>
> But this is not a good approach to edit XML files. Have a look in XML
> parsers like xmllint or xsh (command-line applications).
>
>
----
[Non-text portions of this message have been removed]