List Info

Thread: sed: replace line with file




sed: replace line with file
country flaguser name
United States
2008-02-26 10:31:44
I have a marker that should be replaced with a file.
I thought this would work, but it does not.

/myre/{
d
r myfile
}

On the other hand this works:

/myre/{
r myfile
d
}

How to understand?

Thanks,
Alan Isaac
(sed newbie)

Re: sed: replace line with file
user name
2008-02-26 13:11:13
Hi Alan,

* Alan Isaac wrote on Tue, Feb 26, 2008 at 05:31:44PM CET:
> I have a marker that should be replaced with a file.
> I thought this would work, but it does not.
>
> /myre/{
> d
> r myfile
> }

The 'd' command not only deletes the current line, it also
causes the
script to start over at the next input line.

Cheers,
Ralf



Re: sed: replace line with file
country flaguser name
United States
2008-02-26 14:00:36
Ralf Wildenhues wrote:
> The 'd' command not only deletes the current line, it
also causes the
> script to start over at the next input line.

Ahh.
One might think that is obvious from the documentation,
now that I revisit it, but your kind reply got me there
much quicker than a "RTFM" would have.

Thanks!
Alan

Re: sed: replace line with file
user name
2008-02-26 12:01:46
Alan Isaac <aisaacamerican.edu> wrote:
> /myre/{
> d
> r myfile
> }

The info documentation says:
# `d'
#      Delete the pattern space; immediately start next
cycle.

So anything following a "d" command will never be
executed.


paul



[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )