GNU bug report logs -
#25724
sed (bug or wrong command ?)
Previous Next
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.
Full log
View this message in rfc822 format
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
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.