At 2008-07-20T02:45:51+02:00, Roland Smith wrote:

> Insert a newline in front of every < :
> gsed -e "s/</\n</g" <infile >outfile
> Note that this requires GNU sed. It won't work with BSD sed.

It is possible with native `sed' if the newline character in the
replacement string is properly escaped: two backslashes, followed by
Ctrl-V, and then the newline.

[/home/raghu]% which sed

[/home/raghu]% echo '<hello>world</hello><hello>next world</hello>' | sed 

<hello>next world

However, this doesn't do what the OP wanted: "world", etc., must
appear on separate lines.  Here is a second approximation:

[/home/raghu]% cat foo.sed

[/home/raghu]% cat foo.html
<hi><hello>world</hello>between hells...<hello>next world</hello></hi>

[/home/raghu]% sed -f foo.sed foo.html | sed '/^$/d'
between hells...
next world

Perhaps the pipe to remove blank lines can be incorporated into
`foo.sed', but I don't know how.


N. Raghavendra <[EMAIL PROTECTED]> |
Harish-Chandra Research Institute   |
See message headers for contact and OpenPGP information.

_______________________________________________ mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to