GNU bug report logs - #25724
sed (bug or wrong command ?)

Previous Next

Package: sed;

Reported by: Enrico Magrì <enrico_magri <at> hotmail.com>

Date: Tue, 14 Feb 2017 17:08:02 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

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 25724 in the body.
You can then email your comments to 25724 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#25724; Package sed. (Tue, 14 Feb 2017 17:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Enrico Magrì <enrico_magri <at> hotmail.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Tue, 14 Feb 2017 17:08:02 GMT) Full text and rfc822 format available.

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

From: Enrico Magrì <enrico_magri <at> hotmail.com>
To: "bug-sed <at> gnu.org" <bug-sed <at> gnu.org>
Subject: sed (bug or wrong command ?)
Date: Tue, 14 Feb 2017 10:16:37 +0000
[Message part 1 (text/plain, inline)]
Hi,

I would like to insert new line at the begin of my txt file and in this line to insert the word “ciao”.




The file is this:

C:\config>cat comandi-capture.txt

capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.241

capture CAP-IP-85.205.221.240 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.240

capture CAP-IP-85.205.94.250 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.94.250

capture CAP-IP-85.205.207.116 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.116

capture CAP-IP-85.205.221.220 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.220

capture CAP-IP-85.205.221.218 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.218

capture CAP-IP-85.205.207.99 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.99

capture CAP-IP-85.205.217.252 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.252

capture CAP-IP-85.205.221.245 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.245

capture CAP-IP-85.205.207.46 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.46

capture CAP-IP-85.205.221.239 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.239

capture CAP-IP-85.205.221.232 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.232

capture CAP-IP-85.205.94.238 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.94.238

capture CAP-IP-85.205.221.237 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.237

capture CAP-IP-85.205.207.113 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.113

capture CAP-IP-85.205.217.232 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.232

capture CAP-IP-85.205.217.240 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.240

capture CAP-IP-85.205.217.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.241

capture CAP-IP-85.205.219.160 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.219.160

capture CAP-IP-85.205.221.213 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.213

capture CAP-IP-85.205.221.231 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.231

capture CAP-IP-85.205.221.234 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.234

capture CAP-IP-85.205.221.243 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.243

capture CAP-IP-85.205.221.248 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.248

capture CAP-IP-85.205.221.250 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.250

show capture



I type this command:

sed "1,1s/^/ciao \n /g" comandi-capture.txt



the output is:

C:\config>sed "1,1s/^/ciao \n /g" comandi-capture.txt

ciao n capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.241

capture CAP-IP-85.205.221.240 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.240

capture CAP-IP-85.205.94.250 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.94.250

capture CAP-IP-85.205.207.116 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.116

capture CAP-IP-85.205.221.220 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.220

capture CAP-IP-85.205.221.218 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.218

capture CAP-IP-85.205.207.99 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.99

capture CAP-IP-85.205.217.252 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.252

capture CAP-IP-85.205.221.245 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.245

capture CAP-IP-85.205.207.46 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.46

capture CAP-IP-85.205.221.239 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.239

capture CAP-IP-85.205.221.232 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.232

capture CAP-IP-85.205.94.238 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.94.238

capture CAP-IP-85.205.221.237 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.237

capture CAP-IP-85.205.207.113 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.113

capture CAP-IP-85.205.217.232 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.232

capture CAP-IP-85.205.217.240 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.240

capture CAP-IP-85.205.217.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.241

capture CAP-IP-85.205.219.160 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.219.160

capture CAP-IP-85.205.221.213 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.213

capture CAP-IP-85.205.221.231 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.231

capture CAP-IP-85.205.221.234 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.234

capture CAP-IP-85.205.221.243 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.243

capture CAP-IP-85.205.221.248 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.248

capture CAP-IP-85.205.221.250 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.250

show capture



I would like see the word “ciao” and then  in a new line the rest of the file. It seems that \n is not work or  I type the wrong command :)



The version of sed is the following:

C:\Users\enrico_vf>sed --version
GNU sed version 3.02

Copyright (C) 1998 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.



I tried also with SED of CYGWIN and all woks correctly:



LIT002604+enrico <at> LIT002604 ~/test

$ sed "1,1s/^/ciao\n/g" comandi-capture.txt

ciao

capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.241

capture CAP-IP-85.205.221.240 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.240

capture CAP-IP-85.205.94.250 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.94.250

capture CAP-IP-85.205.207.116 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.116

capture CAP-IP-85.205.221.220 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.220

capture CAP-IP-85.205.221.218 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.218

capture CAP-IP-85.205.207.99 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.99

capture CAP-IP-85.205.217.252 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.252

capture CAP-IP-85.205.221.245 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.245

capture CAP-IP-85.205.207.46 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.46

capture CAP-IP-85.205.221.239 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.239

capture CAP-IP-85.205.221.232 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.232

capture CAP-IP-85.205.94.238 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.94.238

capture CAP-IP-85.205.221.237 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.237

capture CAP-IP-85.205.207.113 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.207.113

capture CAP-IP-85.205.217.232 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.232

capture CAP-IP-85.205.217.240 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.240

capture CAP-IP-85.205.217.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.217.241

capture CAP-IP-85.205.219.160 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.219.160

capture CAP-IP-85.205.221.213 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.213

capture CAP-IP-85.205.221.231 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.231

capture CAP-IP-85.205.221.234 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.234

capture CAP-IP-85.205.221.243 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.243

capture CAP-IP-85.205.221.248 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.248

capture CAP-IP-85.205.221.250 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.250

show capture



LIT002604+enrico <at> LIT002604 ~/test





Thanks in advance for your help



Enrico



[Message part 2 (text/html, inline)]

Information forwarded to bug-sed <at> gnu.org:
bug#25724; Package sed. (Wed, 15 Feb 2017 15:44:01 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Enrico Magrì <enrico_magri <at> hotmail.com>
Cc: 25724 <at> debbugs.gnu.org
Subject: Re: bug#25724: sed (bug or wrong command ?)
Date: Wed, 15 Feb 2017 15:42:51 +0000
tag 25724 notabug
close 25724
stop

Hello,

On Tue, Feb 14, 2017 at 10:16:37AM +0000, Enrico Magrì wrote:
>I would like to insert new line at the begin of my txt file and in this line to insert the word “ciao”.
>
[...]
>C:\config>sed "1,1s/^/ciao \n /g" comandi-capture.txt
>
>ciao n capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.241

[...]
>
>I tried also with SED of CYGWIN and all woks correctly:
>
>$ sed "1,1s/^/ciao\n/g" comandi-capture.txt
>
>ciao
>
>capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE circular-buffer match ip any host 85.205.221.241


[...]

>The version of sed is the following:
>
>C:\Users\enrico_vf>sed --version
>GNU sed version 3.02


First,
sed version 3.02 is 19 years old. (!)
It is highly recommended to upgrade to a newer version.
sed version 4.4 was released just this month.

I'm quite certain that the 'sed' you use on cygwin is newer than
the 'sed' you use directly in cmd.exe.


Second,
Instead of replacing the beginning of the line,
consider using the 'i' (insert') command.
The following should work even on sed-3.02:

  sed -e '1i\' -e 'ciao' comandi-capture.txt

To learn more about this syntax, see the 'i' command in this section:
https://www.gnu.org/software/sed/manual/sed.html#Other-Commands




As such I'm closing this ticket, but discussion can
continue by replying to this thread.

regards,
- assaf





Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 15 Feb 2017 15:44:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 25724 <at> debbugs.gnu.org and Enrico Magrì <enrico_magri <at> hotmail.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 15 Feb 2017 15:44:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-sed <at> gnu.org:
bug#25724; Package sed. (Thu, 16 Feb 2017 22:53:02 GMT) Full text and rfc822 format available.

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

From: Enrico Magrì <enrico_magri <at> hotmail.com>
To: Assaf Gordon <assafgordon <at> gmail.com>
Cc: Enrico Magrì <enrico_magri <at> hotmail.com>,
 "25724 <at> debbugs.gnu.org" <25724 <at> debbugs.gnu.org>
Subject: R: bug#25724: sed (bug or wrong command ?)
Date: Thu, 16 Feb 2017 22:37:47 +0000
Hi Gordon,
thanks for the information; ok I'll try in this way. Do you know the http link where I can download the updated sed.exe for windows ?
Currently I founded only this link for windows OS: http://unxutils.sourceforge.net/
but I believe that it's not the updated package.

Best Regards,
Enrico


-----Messaggio originale-----
Da: Assaf Gordon [mailto:assafgordon <at> gmail.com] 
Inviato: mercoledì 15 febbraio 2017 16:43
A: Enrico Magrì
Cc: 25724 <at> debbugs.gnu.org
Oggetto: Re: bug#25724: sed (bug or wrong command ?)

tag 25724 notabug
close 25724
stop

Hello,

On Tue, Feb 14, 2017 at 10:16:37AM +0000, Enrico Magrì wrote:
>I would like to insert new line at the begin of my txt file and in this line to insert the word “ciao”.
>
[...]
>C:\config>sed "1,1s/^/ciao \n /g" comandi-capture.txt
>
>ciao n capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE 
>circular-buffer match ip any host 85.205.221.241

[...]
>
>I tried also with SED of CYGWIN and all woks correctly:
>
>$ sed "1,1s/^/ciao\n/g" comandi-capture.txt
>
>ciao
>
>capture CAP-IP-85.205.221.241 type raw-data interface OUTSIDE 
>circular-buffer match ip any host 85.205.221.241


[...]

>The version of sed is the following:
>
>C:\Users\enrico_vf>sed --version
>GNU sed version 3.02


First,
sed version 3.02 is 19 years old. (!)
It is highly recommended to upgrade to a newer version.
sed version 4.4 was released just this month.

I'm quite certain that the 'sed' you use on cygwin is newer than the 'sed' you use directly in cmd.exe.


Second,
Instead of replacing the beginning of the line, consider using the 'i' (insert') command.
The following should work even on sed-3.02:

   sed -e '1i\' -e 'ciao' comandi-capture.txt

To learn more about this syntax, see the 'i' command in this section:
https://www.gnu.org/software/sed/manual/sed.html#Other-Commands




As such I'm closing this ticket, but discussion can continue by replying to this thread.

regards,
 - assaf


Information forwarded to bug-sed <at> gnu.org:
bug#25724; Package sed. (Thu, 16 Feb 2017 22:58:01 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: Enrico Magrì <enrico_magri <at> hotmail.com>,
 Assaf Gordon <assafgordon <at> gmail.com>
Cc: "25724 <at> debbugs.gnu.org" <25724 <at> debbugs.gnu.org>
Subject: Re: bug#25724: R: bug#25724: sed (bug or wrong command ?)
Date: Thu, 16 Feb 2017 16:57:48 -0600
[Message part 1 (text/plain, inline)]
[top-posting is frowned on within technical lists]

On 02/16/2017 04:37 PM, Enrico Magrì wrote:
> Hi Gordon,
> thanks for the information; ok I'll try in this way. Do you know the http link where I can download the updated sed.exe for windows ?
> Currently I founded only this link for windows OS: http://unxutils.sourceforge.net/
> but I believe that it's not the updated package.

The cygwin project [https://cygwin.com] has an up-to-date sed 4.4
available for windows
[https://cygwin.com/ml/cygwin-announce/2017-02/msg00020.html]
<bias>
and a maintainer that's more responsive than the unxutils folks (seeing
as how that maintainer is me, and I read this list :)
</bias>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-sed <at> gnu.org:
bug#25724; Package sed. (Fri, 17 Feb 2017 02:21:01 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Enrico Magrì <enrico_magri <at> hotmail.com>
Cc: "25724 <at> debbugs.gnu.org" <25724 <at> debbugs.gnu.org>
Subject: Re: bug#25724: R: bug#25724: sed (bug or wrong command ?)
Date: Thu, 16 Feb 2017 21:20:27 -0500
Hello,

> On Feb 16, 2017, at 17:57, Eric Blake <eblake <at> redhat.com> wrote:
> 
> On 02/16/2017 04:37 PM, Enrico Magrì wrote:
>> Do you know the http link where I can download the updated sed.exe for windows ?
> 
> The cygwin project [https://cygwin.com] has an up-to-date sed 4.4
> available for windows

Cygwin is the best source for gnu programs on windows (and non-gnu programs, too).
It is highly recommended to use cygwin.

If you absolutely can not use cygwin,
you'll find here links for sed versions compiled for windows:
https://lists.gnu.org/archive/html/bug-sed/2017-01/msg00076.html
but please be aware these are unofficial, unsupported versions.

regards,
 - assaf



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 17 Mar 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 98 days ago.

Previous Next


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