bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25724: sed (bug or wrong command ?)


From: Assaf Gordon
Subject: bug#25724: sed (bug or wrong command ?)
Date: Wed, 15 Feb 2017 15:42:51 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]