[ILUG] Re: sed problem
Paul Dunne
paul at dunne.ie.eu.org
Fri Sep 10 16:05:42 IST 2004
Dave Neary writes,
I was reading the Sed question to the list in the archives (sorry, still
not re-subscribed :) and Padraig's answer, which is no good...
John A. Kinsella wrote:
> I'd like to do a simple conversion
> s/Maple 8/Maple 9/g
> in a bunch of Maple *.mws files using sed.
>
> Is there a way to tell sed to do the substitution while preserving the
> line breaks (which Maple seems to need).
I take the "line breaks" to be possible newlines between "Maple" and "8".
So, unless I mis-understand, surely this is what's required?
#!/bin/sed -f
# simple case
s/Maple 8/Maple 9/g
# line break (with optional spaces)
/Maple *$/{
N
s/Maple *\n8/Maple\
9/
}
(If you have newlines within the word "maple", it's a pain but stil doable
by extending this technique).
--
Paul Dunne | paul at dunne.ie.eu.org | http://dunne.yi.org/
More information about the ILUG
mailing list