Re: How can I use sed to insert a character into a file?

Liste des GroupesRevenir à ol misc 
Sujet : Re: How can I use sed to insert a character into a file?
De : zlatko (at) *nospam* gmx.at (Thomas Zajic)
Groupes : comp.os.linux.misc
Date : 08. Jul 2024, 21:56:01
Autres entêtes
Message-ID : <slrnv8oh2h.fr2.zlatko@disclosure.zlatk0.net>
References : 1
User-Agent : slrn/1.0.3 (Linux)
* Jon Danniken <nonesuch@nottodaynortomorroreither.org>

I'm sure this is trivial to most here, but sed confounds me.  I have an
xml file with content following this format:
 
<type:color>000000</type:color>
<type:color>FFFFFF</type:color>
 
The information within the tags are hex colors (many different colors),
but they need to begin with a pound sign (#) to work in a particular
application, ie:
 
<type:color>#000000</type:color>
<type:color>#FFFFFF</type:color>
 
How can I use sed to append the pound symbol in this file? Using sed 4.8

sed -i -e 's,<type:color>,<type:color>#,' file.xml

Could be done more sophistic & elegant, but I think it's more readable
this way. :-)


HTH & HAND
Thomas
--
=-------------------------------------------------------------------------=
-   Thomas "ZlatkO" Zajic    <zlatko@gmx.at>    Linux-6.6 & slrn-1.0.3a   -
-    "In layman's terms: speedy thing goes in, speedy thing comes out."   -
=-------------------------------------------------------------------------=

Date Sujet#  Auteur
8 Jul 24 * How can I use sed to insert a character into a file?4Jon Danniken
8 Jul 24 +- Re: How can I use sed to insert a character into a file?1Nuno Silva
8 Jul 24 `* Re: How can I use sed to insert a character into a file?2Thomas Zajic
8 Jul 24  `- Re: How can I use sed to insert a character into a file?1Jon Danniken

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal