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 J
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@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@LIT002604 ~/test
Thanks in advance for your help
Enrico