GNU bug report logs - #49590
Error in GNU sed manual

Previous Next

Package: sed;

Reported by: Matthew Hoffman <matthewchoffman <at> protonmail.com>

Date: Fri, 16 Jul 2021 01:51:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Matthew Hoffman <matthewchoffman <at> protonmail.com>
To: 49590 <at> debbugs.gnu.org
Subject: bug#49590: Error in GNU sed manual
Date: Fri, 16 Jul 2021 00:45:07 +0000
[Message part 1 (text/plain, inline)]
Dear GNU people:

The GNU sed manual seems to have an error in it.

In this section:

6.3 Multiline techniques - using D,G,H,N,P to
process multiple lines

You have this example code:

sed '/./{H;$!d} ; x ; s/^/\nSTART-->/ ; s/$/\n<--END/' input.txt

The input file you give is:

a a a aa aaa
aaaa aaaa aa
aaaa aaa aaa
bbbb bbb bbb
bb bb bbb bb
bbbbbbbb bbb
ccc ccc cccc
cccc ccccc c
cc cc cc cc

and the output promised is:

START-->
a a a aa aaa
aaaa aaaa aa
aaaa aaa aaa
<--END
START-->
bbbb bbb bbb
bb bb bbb bb
bbbbbbbb bbb
<--END
START-->
ccc ccc cccc
cccc ccccc c
cc cc cc cc
<--END

This seemed wrong to me, because as I understood it the '$' symbol should indicate the last line of the file, not merely a blank line, so I executed it on my GNU sed 4.7, and this is the output you get:

START-->
a a a aa aaa
aaaa aaaa aa
aaaa aaa aaa
bbbb bbb bbb
bb bb bbb bb
bbbbbbbb bbb
ccc ccc cccc
cccc ccccc c
cc cc cc cc
<--END

This is what I expected based on other documentation, and it is what happened.

I thought you would want to know.

God bless,
Matthew Hoffman
[Message part 2 (text/html, inline)]

This bug report was last modified 3 years and 336 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.