Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!tellab5!vpnet!dattier From: dattier@vpnet.chi.il.us (David W. Tamkin) Newsgroups: comp.unix.questions Subject: Re: i command in sed - only one address? Message-ID: <1991Apr30.205203.10588@vpnet.chi.il.us> Date: 30 Apr 91 20:52:03 GMT References: <1991Apr29.131718.26624@ux1.cso.uiuc.edu> <1991Apr29.201315.7790@athena.mit.edu> Organization: VPnet Public Access Unix, Villa Park, Illinois 60181-2206 Lines: 26 In article <1991Apr29.131718.26624@ux1.cso.uiuc.edu> ceblair@ux1.cso.uiuc.edu (Charles Blair) wrote: | I would like to put a line before ranges in a file. Something like | sed '/A/,/B/i\ | INSERTED LINE' < file1 > file2 | but when I try this, I get an error message saying ``only one address.'' Believe it or not, this has worked in my experience: sed ' /A/,/B/{ i\ INSERTED LINE }' < file1 > file2 Since the braces protect the 'i' command from seeing the range and thus 'i' is being fed only one address at a time, it doesn't complain. David Tamkin PO Box 7002 Des Plaines IL 60018-7002 dattier@vpnet.chi.il.us GEnie:D.W.TAMKIN CIS:73720,1570 MCIMail:426-1818 708 518 6769 312 693 0591 "Parker Lewis Can't Lose" mailing list: flamingo-request@esd.sgi.com (relay) flamingo-request@ddsw1.mcs.com (digest)