Subject: Unexpected output

From: walonen <[email-masked]>
Date: Sun, 12 Mar 2023 09:05:37 +0100

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: <[email-masked]>.

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