Re: grep sed replace

"Daniel Goldman [email protected] [sed-users]" <[email protected]> Thu, 10 Nov 2016 09:03:46 -0800
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Right. It should be one less n command. And the -r option does not hurt 
to be included, but is not needed here.

$ cat c.txt
Mike Blue
monday
0.8
Tom Red
friday
0.8
Virginie Rose
saturday
0.8

$ sed '/Tom Red/ {n;n;s/.*/NEW STRING/}' c.txt
Mike Blue
monday
0.8
Tom Red
friday
NEW STRING
Virginie Rose
saturday
0.8

On 11/10/2016 8:29 AM, MOKRANI Rachid [email protected] 
[sed-users] wrote:
> It's OK. Just need 2 n.
>
> Thanks.
>
> -----Message d'origine-----
> De : MOKRANI Rachid
> Envoyé : jeudi 10 novembre 2016 17:09
> À : '[email protected]'
> Objet : RE: grep sed replace
>
> Hi Thierry,
>
> If I don't make a mistake, It seem that your exemple add a line with " MY NEW STRING " after the third line "0.8".
> I need to REPLACE 0.8 by "MY NEW STRING"
>
>
>
>
> -----Message d'origine-----
> De : [email protected] [mailto:[email protected]]
> Envoyé : jeudi 10 novembre 2016 15:35
> À : [email protected]
> Objet : Re: grep sed replace
>
>
>
> sed -r '/Tom/{n;n;n;s|.*|MY NEW STRING|}' yourfile
>
>
> find Tom, go 3 lines down, change line
>
> On 10/11/16 16:03, MOKRANI Rachid [email protected] [sed-users] wrote:
>> Paul Brown
>> monday
>> 0.8
>> Mike Blue
>> monday
>> 0.8
>> Tom Red
>> friday
>> 0.8
>> Virginie Rose
>> saturday
>> 0.8
>> David Brown
>> saturday
>> 0.7
>> Brian Yellow
>> monday
>> 0.55
>> Tom Black
>> thuesday
>> 0.4
>
>
>
>
> ------------------------------------
> Posted by: Thierry Blanc <[email protected]>
> ------------------------------------
>