Replace symbols > and < with &lt; and &gt;

Replace symbols > and < with &lt; and &gt;

am 16.04.2008 22:27:27 von jhaberla99

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

Re: Replace symbols > and < with &lt; and &gt;

am 16.04.2008 22:30:19 von someone

jhaberla99@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

Re: Replace symbols > and < with &lt; and &gt;

am 16.04.2008 23:30:55 von Chris Mattern

On 2008-04-16, jhaberla99@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
>

"&" 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 ">" becomes
">gt;". You need to escape it to tell sed not to treat it
as a special character:

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



--
Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities

Re: Replace symbols > and < with &lt; and &gt;

am 17.04.2008 08:21:15 von Stephane CHAZELAS

2008-04-16, 13:27(-07), jhaberla99@gmail.com:
> 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

If you have GNU recode:

recode ..html

--
Stéphane