From: jhaberla99 on
Is there a method to replace the greater than and less than symbols
with < and > for processing in an XML file? I had tried to use
sed similar to the following but it does not work:

$ echo "test>1w3" |sed 's/>/>/g'
test>gt;1w3

From: John W. Krahn on
jhaberla99(a)gmail.com wrote:
> Is there a method to replace the greater than and less than symbols
> with < and > for processing in an XML file? I had tried to use
> sed similar to the following but it does not work:
>
> $ echo "test>1w3" |sed 's/>/>/g'
> test>gt;1w3

echo "test>1w3" |sed 's/>/\>/g'


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
From: Chris Mattern on
On 2008-04-16, jhaberla99(a)gmail.com <jhaberla99(a)gmail.com> wrote:
> Is there a method to replace the greater than and less than symbols
> with &lt; and &gt; for processing in an XML file? I had tried to use
> sed similar to the following but it does not work:
>
> $ echo "test>1w3" |sed 's/>/&gt;/g'
> test>gt;1w3
>

"&" is a special character in the replacement operand of
substitution REs, meaning "what got matched by the match
operand." In this case, that was ">", so "&gt;" becomes
">gt;". You need to escape it to tell sed not to treat it
as a special character:

$ echo "test>1w3" |sed 's/>/\&gt;/g'
test&gt;1w3



--
Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities
From: Stephane CHAZELAS on
2008-04-16, 13:27(-07), jhaberla99(a)gmail.com:
> Is there a method to replace the greater than and less than symbols
> with &lt; and &gt; for processing in an XML file? I had tried to use
> sed similar to the following but it does not work:
>
> $ echo "test>1w3" |sed 's/>/&gt;/g'
> test>gt;1w3

If you have GNU recode:

recode ..html

--
St�phane