Path: utzoo!attcan!uunet!husc6!yale!cs.utexas.edu!meyering From: meyering@cs.utexas.edu (Jim Meyering) Newsgroups: comp.editors Subject: Re: sed address arithmetic Message-ID: <914@ai.cs.utexas.edu> Date: 22 Sep 90 16:33:27 GMT References: <8738@neptune.inf.ethz.ch> Distribution: comp Organization: U of TX at Austin CS Dept Lines: 19 In article <8738@neptune.inf.ethz.ch> reberhar@iiic.ethz.ch (Rolf Georg Eberhardt) writes: >Is it possible to do address arithmetic in sed? > I would like to do something like > >/searchpattern/+3 s/^// Here's another solution (when reasonable, I prefer to avoid sed's multiline commands: i,a,c...): This is a bit ugly, though... % sed '/searchpattern/{N;N;p;g;N;s/^//;}' With at least SunOS4.0.3's /bin/sed, (due to a bug) there must be a semicolon following the `s' command at the end of a {} group. -- Jim Meyering meyering@cs.utexas.edu