GNU bug report logs -
#62144
Unexpected output
Previous Next
Reported by: walonen <walonen <at> gmx.net>
Date: Sun, 12 Mar 2023 13:23: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 62144 in the body.
You can then email your comments to 62144 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#62144
; Package
sed
.
(Sun, 12 Mar 2023 13:23:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
walonen <walonen <at> gmx.net>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Sun, 12 Mar 2023 13:23:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
I have found an unexpected behavior of sed. I would expect the same
output for the following commands:
sed '/root/!d' /etc/passwd
sed '/root/{ !d }' /etc/passwd
$ sed --version
sed (GNU sed) 4.7
Packaged by Debian
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
Paolo Bonzini, Jim Meyering, and Assaf Gordon.
GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
Fehlerberichte bitte per E-Mail (auf englisch) an: <bug-sed <at> gnu.org>.
Seen ouotput:
$ sed '/root/!d' /etc/passwd
root:x:0:0:root:/root:/bin/bash
$ sed '/root/{ !d }' /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
... the whole file
BR,
Stefan Scheruebl
[Message part 2 (text/html, inline)]
Reply sent
to
Jim Meyering <jim <at> meyering.net>
:
You have taken responsibility.
(Tue, 14 Mar 2023 16:25:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
walonen <walonen <at> gmx.net>
:
bug acknowledged by developer.
(Tue, 14 Mar 2023 16:25:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 62144-done <at> debbugs.gnu.org (full text, mbox):
tags 62144 notabug
stop
On Sun, Mar 12, 2023 at 7:24 AM walonen <walonen <at> gmx.net> wrote:
> I have found an unexpected behavior of sed. I would expect the same
> output for the following commands:
>
> sed '/root/!d' /etc/passwd
> sed '/root/{ !d }' /etc/passwd
Thanks for the report, but the '!' modifier must be applied to an
address specification, so your latter command should be spelled like
this:
sed '/root/!{ d }' /etc/passwd
and that is equivalent to the first one.
Quoting the info documentation on this topic:
Appending the '!' character to the end of an address specification
(before the command letter) negates the sense of the match. That is, if
the '!' character follows an address or an address range, then only
lines which do _not_ match the addresses will be selected. The
following command replaces the word 'hello' with 'world' only in lines
_not_ containing the word 'apple':
sed '/apple/!s/hello/world/' input.txt > output.txt
The following command replaces the word 'hello' with 'world' only in
lines 1 to 3 and 18 till the last line of the input file (i.e.
excluding lines 4 to 17):
sed '4,17!s/hello/world/' input.txt > output.txt
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 12 Apr 2023 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 32 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.