Deutsch English Français Italiano |
<slrnv8oh2h.fr2.zlatko@disclosure.zlatk0.net> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Thomas Zajic <zlatko@gmx.at> Newsgroups: comp.os.linux.misc Subject: Re: How can I use sed to insert a character into a file? Date: Mon, 8 Jul 2024 21:56:01 +0200 Lines: 30 Message-ID: <slrnv8oh2h.fr2.zlatko@disclosure.zlatk0.net> References: <v6hc36$vv1m$1@dont-email.me> X-Trace: individual.net 6igzVBHXLd+EY+Py0M+IYgeWZa5E9lWoXuQtnhITih1iX5EnU= X-Orig-Path: news.zlatk0.net!not-for-mail Cancel-Lock: sha1:384zyiuk9qCsAdn5qLpfyZjUKeM= sha256:7EbpYQv4CZ008d43EW5BOuQ2i0Mw+qIZCs7ZeYu9CTk= X-Signature-Color: blue X-Eric-Conspiracy: There is no conspiracy X-Registered-Linux-User: 63207 X-Organization: FAQ-Team for at.linux X-Face: $Bj#y0]DSsWPX(UJnJ@"s}e}4FU`ep9qSk<Gbp@G"+\UxynXojl4S)|.Ff/Y72G5Cc&s? $HK/bs)HT-L.Ccf>`+*:=e/BlD{EJ;\k:{+y(sfWA}Vm:U:Arl;!r(B@rw^}ON`|mW?&o&y6EpRq[ ;D6Tv;zGnMz~u User-Agent: slrn/1.0.3 (Linux) Bytes: 2097 * 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." - =-------------------------------------------------------------------------=