GNU bug report logs - #50361
Error in first example in documentation

Previous Next

Package: sed;

Reported by: Robert Spanjaard <r.spanjaard <at> arumes.com>

Date: Fri, 3 Sep 2021 19:04:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50361 in the body.
You can then email your comments to 50361 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#50361; Package sed. (Fri, 03 Sep 2021 19:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Robert Spanjaard <r.spanjaard <at> arumes.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Fri, 03 Sep 2021 19:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Robert Spanjaard <r.spanjaard <at> arumes.com>
To: bug-sed <at> gnu.org
Subject: Error in first example in documentation
Date: Fri, 3 Sep 2021 20:26:19 +0200
On this website...

https://www.gnu.org/software/sed/manual/sed.html#Invoking-sed

In 2.1, the very first example in the documentation states that...

	sed 's/hello/world/' input.txt > output.txt

... replaces ALL occurences of 'hello' to 'world in input.txt.

But the g flag is missing. The provided command only replaces the FIRST 
occurence.

-- 
Kind regards,

Robert Spanjaard




Information forwarded to bug-sed <at> gnu.org:
bug#50361; Package sed. (Sat, 04 Sep 2021 10:27:02 GMT) Full text and rfc822 format available.

Message #8 received at 50361 <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: Robert Spanjaard <r.spanjaard <at> arumes.com>
Cc: 50361 <at> debbugs.gnu.org
Subject: Re: bug#50361: Error in first example in documentation
Date: Sat, 4 Sep 2021 12:26:17 +0200
On Fri, 3 Sep 2021 20:26:19 +0200, Robert Spanjaard
<r.spanjaard <at> arumes.com> wrote:

> https://www.gnu.org/software/sed/manual/sed.html#Invoking-sed
>
> In 2.1, the very first example in the documentation states that...
>
> 	sed 's/hello/world/' input.txt > output.txt
>
> ... replaces ALL occurences of 'hello' to 'world in input.txt.
>
> But the g flag is missing. The provided command only replaces the FIRST
> occurence.
>

I guess it depends on how you interpret it...for the following input.txt:

----------
hello
foo
bar
hello
xxx
hello
----------

the given code does indeed replace all occurrences of "hello" to "world".
Perhaps the only thing that is needed is a slightly better wording.

--
D.




Information forwarded to bug-sed <at> gnu.org:
bug#50361; Package sed. (Sat, 04 Sep 2021 16:45:01 GMT) Full text and rfc822 format available.

Message #11 received at 50361 <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: Robert Spanjaard <r.spanjaard <at> arumes.com>
Cc: 50361 <at> debbugs.gnu.org
Subject: Re: bug#50361: Error in first example in documentation
Date: Sat, 4 Sep 2021 18:44:46 +0200
(keeping the list in the loop)

On Sat, 4 Sep 2021 17:43:27 +0200, Robert Spanjaard
<r.spanjaard <at> arumes.com> wrote:

> I'm not a regular sed user. I had an HMTL file that had about 70 list
> elements on a single line, and I wanted to change that. So I thought I'd
> use sed to change every occurence of "li><li" into "li>\n<li".
>
> sed 's/<\/li><li>/<\/li>\n<li>/' list.html > formattedlist.html
>
> According to the manual, this should work. This is exactly what the
> manual tells me to do to replace *all* occurences in the file list.html.
>
> That is NOT a matter of interpretation.

Since I foresee this rapidly becoming a sterile discussion, I'll only add
this:

for files that do not have multiple occurrences of the same pattern on a
single line, the statement in the manual is correct. The only thing missing
is a note specifying just that.

Good luck with your replacements.

--
D.




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Sun, 05 Sep 2021 10:08:01 GMT) Full text and rfc822 format available.

Notification sent to Robert Spanjaard <r.spanjaard <at> arumes.com>:
bug acknowledged by developer. (Sun, 05 Sep 2021 10:08:02 GMT) Full text and rfc822 format available.

Message #16 received at 50361-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Davide Brini <dave_br <at> gmx.com>
Cc: 50361-done <at> debbugs.gnu.org, Robert Spanjaard <r.spanjaard <at> arumes.com>
Subject: Re: bug#50361: Error in first example in documentation
Date: Sun, 5 Sep 2021 12:07:31 +0200
[Message part 1 (text/plain, inline)]
On Sat, Sep 4, 2021 at 6:46 PM Davide Brini <dave_br <at> gmx.com> wrote:
>
>
> (keeping the list in the loop)
>
> On Sat, 4 Sep 2021 17:43:27 +0200, Robert Spanjaard
> <r.spanjaard <at> arumes.com> wrote:
>
> > I'm not a regular sed user. I had an HMTL file that had about 70 list
> > elements on a single line, and I wanted to change that. So I thought I'd
> > use sed to change every occurence of "li><li" into "li>\n<li".
> >
> > sed 's/<\/li><li>/<\/li>\n<li>/' list.html > formattedlist.html
> >
> > According to the manual, this should work. This is exactly what the
> > manual tells me to do to replace *all* occurences in the file list.html.
> >
> > That is NOT a matter of interpretation.
>
> Since I foresee this rapidly becoming a sterile discussion, I'll only add
> this:
>
> for files that do not have multiple occurrences of the same pattern on a
> single line, the statement in the manual is correct. The only thing missing
> is a note specifying just that.
>
> Good luck with your replacements.

Thank you both. I have addressed this and some related (and unrelated
things I noticed along the way) with the attached patch:
[0001-doc-tighten-clarify-wording-e.g.-re-g-modifier.patch (application/octet-stream, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Oct 2021 11:24:05 GMT) Full text and rfc822 format available.

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

Previous Next


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