i command in sed - only one address?

David W. Tamkin dattier at vpnet.chi.il.us
Wed May 1 06:52:03 AEST 1991


In article <1991Apr29.131718.26624 at ux1.cso.uiuc.edu>
ceblair at 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 at 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 at esd.sgi.com (relay)  flamingo-request at ddsw1.mcs.com (digest)



More information about the Comp.unix.questions mailing list