Re: sed 4.2.1 bug

Davide Brini <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
On Tue, 10 Jul 2012 22:31:32 +0530, Sophia Jacob <[email protected]>
wrote:

> Thank you very much Paolo!
> 
> Still it looks like 'D' is not working at all in this case. I ran this:
> $ sed -n '=;i\
> ----
> ;p;H;4,${g;i\
> +++
> ;=;D;h}' c    # c is the same file that contains 5 lines 1\n2\n3\n4\n5
> 
> (Print the pattern space at the beginning of the command. So, if 'D'
> deletes the first segment of the pattern space (which will contain
> "1\n2\n3\n4\n", in the next itteration, 'p' should be printing
> "2\n3\n\4". But it keeps printing "1\n2\n3\n4"!

At line 4 the hold space (which is copied to the pattern space by the "g"
command) contains

\n1\n2\n3\n4

note the leading \n. This, the "D" command only deletes the first \n,
leaving 1\n2\n3\n4.


-- 
D.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.