List Info

Thread: Problem with sed to insert a new line




Problem with sed to insert a new line
country flaguser name
France
2007-06-28 05:32:33
Hi everyone,

I have a file called "test" with the following
lines:
###
a
b

d
e
f
###

With sed, i want to insert the "c" letter after
"b" letter. Logically 
simple, but not for me.

Here is my command : # sed -i.old -e "4ic"

I have this message : sed: 1: "4ic": extra
characters after  at the 
end of i command

I need help please.

Thank you 

Olivier.
**
_______________________________________________
freebsd-questionsfreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribefreebsd.org"

Re: Problem with sed to insert a new line
user name
2007-06-28 05:36:25
On 6/28/07, Olivier Regnier <oregnieroregnier.net> wrote:
> Hi everyone,
>
> I have a file called "test" with the
following lines:
> ###
> a
> b
>
> d
> e
> f
> ###
>
> With sed, i want to insert the "c" letter
after "b" letter. Logically
> simple, but not for me.
>
> Here is my command : # sed -i.old -e "4ic"
>
> I have this message : sed: 1: "4ic": extra
characters after  at the
> end of i command

AFAIK, with our sed you can only do that with multiline
command:
% sed -i.old -e "4i\<press enter>
c" test

The backslash is doubled, because shells interpret
backslash-newline as a space. With GNU sed it's
much easier.
_______________________________________________
freebsd-questionsfreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribefreebsd.org"

Re: Problem with sed to insert a new line
country flaguser name
France
2007-06-28 05:55:10
Andrew Pantyukhin a écrit :
> On 6/28/07, Olivier Regnier <oregnieroregnier.net> wrote:
>> Hi everyone,
>>
>> I have a file called "test" with the
following lines:
>> ###
>> a
>> b
>>
>> d
>> e
>> f
>> ###
>>
>> With sed, i want to insert the "c" letter
after "b" letter. Logically
>> simple, but not for me.
>>
>> Here is my command : # sed -i.old -e
"4ic"
>>
>> I have this message : sed: 1: "4ic":
extra characters after  at the
>> end of i command
>
> AFAIK, with our sed you can only do that with
multiline
> command:
> % sed -i.old -e "4i\<press enter>
> c" test
>
> The backslash is doubled, because shells interpret
> backslash-newline as a space. With GNU sed it's
> much easier.
> _______________________________________________
> freebsd-questionsfreebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
> To unsubscribe, send any mail to 
> "freebsd-questions-unsubscribefreebsd.org"
Hello,

Ok with your command :
% sed -i.old -e "4i\<press enter>
c" test
It's good but if i want to use my command in a shell script
? It's 
possible or not 

Thank you 

Olivier.

_______________________________________________
freebsd-questionsfreebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-que
stions
To unsubscribe, send any mail to
"freebsd-questions-unsubscribefreebsd.org"

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )