From unknown Tue Jun 24 05:10:03 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#62144 <62144@debbugs.gnu.org> To: bug#62144 <62144@debbugs.gnu.org> Subject: Status: Unexpected output Reply-To: bug#62144 <62144@debbugs.gnu.org> Date: Tue, 24 Jun 2025 12:10:03 +0000 retitle 62144 Unexpected output reassign 62144 sed submitter 62144 walonen severity 62144 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 12 09:22:58 2023 Received: (at submit) by debbugs.gnu.org; 12 Mar 2023 13:22:58 +0000 Received: from localhost ([127.0.0.1]:59402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbLf8-0005mk-Ag for submit@debbugs.gnu.org; Sun, 12 Mar 2023 09:22:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:49088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbGi8-0002Vq-NJ for submit@debbugs.gnu.org; Sun, 12 Mar 2023 04:05:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbGi7-0001c9-Vl for bug-sed@gnu.org; Sun, 12 Mar 2023 04:05:44 -0400 Received: from mout.gmx.net ([212.227.15.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbGi5-00024v-Ko for bug-sed@gnu.org; Sun, 12 Mar 2023 04:05:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1678608338; i=walonen@gmx.net; bh=ZG497WYddzzDCeBWzTExE1wQsZYiw5wWbLGurAlZcvU=; h=X-UI-Sender-Class:Date:To:From:Subject; b=INb3SAa0fAEK/bLtA0ojuyf0LQxpIG7saXajuxj9YclyK1VRnqsq69R+pXWDVLnoJ kCVxiR9ZG0FnSyhRcPVOStI44uE2UnmvLiIEy3KM8KawIupjHDACKso4AXtK3oA0kt /1/WT4zWW5jQlkJuMtA39HS4GXnAtW/8OuPboYi7J6zpU8CBbO9iVpGgDTo9/zxe04 um077VdF+SbEJh5nde/Uqzvx8cQxoHn0FlO9ijnbuxVnk+ef+RtoHWXY84nX7kOaBY UxLiy6PjIQgpz2nuTRcwZIa72+RLxi3EwvQEvWHS1wnJbH+CvgoGzrMhQ9Kh18K98q uD+PfdYLXxfBA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.178.10] ([91.46.23.63]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MlNpH-1qFagR1oSb-00lkIM for ; Sun, 12 Mar 2023 09:05:38 +0100 Content-Type: multipart/alternative; boundary="------------HCzOlfVzgWshosyZPtzVj0XF" Message-ID: Date: Sun, 12 Mar 2023 09:05:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: bug-sed@gnu.org From: walonen Subject: Unexpected output X-Provags-ID: V03:K1:26fYr3ufJopgDIyjTZzQb8WDBYIenGmoH9K7srmNfpdWvyg6lrE +iposWv65CyCGEq6rbd4476dfcKbaJDEJnAAGe1Adc44EVPkFoIS8xgJ9Jn/XwiYDAxBUO/ hW0WsHK7np+QU5BEFz7YJgOziFOdiAJQMPL2qwiG+NJssL7MCo4+jAdDZoUpQE0p8aiCO4c G69X9o6D6AEALCOenxQig== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:4OD8phBNe1A=;dE9VwBKdbkgGM/Px7v17IXkyDTo P9I7rrtaDU9MWP5Jeq7CA9nchjOEjYaiwO//zVUNJtdZao8xR/1TvpurmxE7miBoEnzd960GW xOgwJ5JR2npRZm359jzScPfP0UrLaY1fNZFmh57DfWwzWMpKYf6YkrYDsFk2gkMDWSrMmVbGE gr/YoNLSecStTiU22ov5S7Qypj4ZZpbmoZggB2Ydi/+yDXIdjcR29FbLwn+4MR7xrVbiifjeJ PwhfrYOtEtHhwvANKmOBj0a096kEDmnLEVSKlvYgNOd7iHxiJ4kihIbAn5eBmBjk/WEJoMXIy dUs33CzwnMXfHfl2nAo6N2Ty3zm8eZd76JiWkrRuf3nqILbnXgWucJIm8EBZEFzGsUyLMj6PI qIhbqoeOOi4Xucp6EqoUve0YgKgmdlFOWt3RMs6v3ZrNrikKrOXjKnS88FmJyJugSS3E5z+yK xe/oSkkSiknGf5Tf5vyoGpRP/fwxkIwWaNfI78fWwV4bfj8G44QDZpMdI4kv+/0HUOd2+Iypv iN4f0J1OuIhGUg67ODXZ3dTu3rbvoJpDVFSaeXCkO/4A8tEN3WZj7UJ14F8pB/cjcNmouff2D Z7gqH5RkzLxH4V0UcGouIa/cCFpVqBtc1A6635NNa1RUv2wNAGHtrQ0E9deeD47oIN5X6fQFk EKkoWJnPK/ElsVZBsVTwOhKHI0Qsb6dH8RzGWczrxkKaO3oNFiwGDctMs65xGpAjU5zSpBdaB A5X1pzX2CdZd8WpQtObsDBmIfGdlYM1AiWJLybhTOp7B4Ab2Yx8ye/ao1BZC+jplMR1wpSV04 WsvWtqpbHaFRDOMCjKGzJ6EHJhjnD/nNkq4nnSVZYPHeq/uQow0Me29tNnbrVPajctlyLJiqi zw1IrTCnaSmXjIQ/w80QVKoiPm9LIAPZjnL5XwLXZPY5J+3x++0VlcEZI1zLF5Yyqe8LD58x6 ZueNWg== Received-SPF: pass client-ip=212.227.15.19; envelope-from=walonen@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 12 Mar 2023 09:22:56 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) This is a multi-part message in MIME format. --------------HCzOlfVzgWshosyZPtzVj0XF Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable 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 . 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: . General help using GNU software: . Fehlerberichte bitte per E-Mail (auf englisch) an: . 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 --------------HCzOlfVzgWshosyZPtzVj0XF Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit 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@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
--------------HCzOlfVzgWshosyZPtzVj0XF-- From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 14 12:24:49 2023 Received: (at 62144-done) by debbugs.gnu.org; 14 Mar 2023 16:24:49 +0000 Received: from localhost ([127.0.0.1]:38331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pc7SD-0001Ak-8D for submit@debbugs.gnu.org; Tue, 14 Mar 2023 12:24:49 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]:42849) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pc7SB-0001AS-91 for 62144-done@debbugs.gnu.org; Tue, 14 Mar 2023 12:24:47 -0400 Received: by mail-lf1-f46.google.com with SMTP id s22so20746830lfi.9 for <62144-done@debbugs.gnu.org>; Tue, 14 Mar 2023 09:24:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678811081; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LiQ5gQubZaOMpEjwhp5g8KYr/x2ZoaEIEoV1CMK2PoM=; b=eKxHXxgJm55yK/LDM2Z/BixDLajy+F3aEhi7aDHQOyDUd4MsjA4C4olPiPfz59PDEP ud4R3wZEOY0XoZ312f7meScIEZsJoXzMNYK6V3Ro4P8qUk+/nK+5fJxv/EC+9MhCP24I fsJbH4/dzolQg6PbaOleL6ERYDb+9iliJ0+lcF4eIYKCtMOecpBIT0YvjWx+YMdTXtFQ AEMd6vCs9z+ZQoZdnRIEQ7WqWKDK6rC/LINlpoC1E9o+XCckFI1Ox5qbF9XgvD2N91k8 ap9FBfZxxop6kC8QsOkwr/co5egtmoqFn/C2XGoNd8S7m1yikJTlmPUElqTANis+1sR8 oFmw== X-Gm-Message-State: AO0yUKXBh3XZTEh6UKNrPYAAuJHAXosYeUmGy/kbTwFkT+BwFl5suQR5 RhqWxahTS2URYqth3qGHugJ0kgRM6T/k7S/o2wk= X-Google-Smtp-Source: AK7set9Ju7LA3FfKCy8/80FPOk4oecLw7FeKpTpqDw77ajfx6UtNL31jLyapJ8dNGdEDVfn7SUuy4gJ095olK8RWq8c= X-Received: by 2002:ac2:5508:0:b0:4d5:ca32:6aea with SMTP id j8-20020ac25508000000b004d5ca326aeamr938133lfk.10.1678811080990; Tue, 14 Mar 2023 09:24:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jim Meyering Date: Tue, 14 Mar 2023 09:24:28 -0700 Message-ID: Subject: Re: bug#62144: Unexpected output To: walonen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 62144-done Cc: 62144-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) tags 62144 notabug stop On Sun, Mar 12, 2023 at 7:24=E2=80=AFAM walonen 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 From unknown Tue Jun 24 05:10:03 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 12 Apr 2023 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator