Re: how to use sed to replace a single occurrence in a file

From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 11/29/04


Date: 28 Nov 2004 20:00:54 -0800

moran@hotmail.co.il (Moran Levy) wrote in message news:

>
> I want to replace a single occcurence of the pattern in a text file.
> Let's suppose I want to replace the first occurrence. How do I use sed
> to do this ?
>
>
> Example:
> text file -
> 1234
> 5678
> 1234
> 5678
> 1234
>
> I want to replace the first occurence of 1234 to 9999
>

   sed -e '1s/RE/9999/;t' -e '1,/RE/s/RE/9999/' yourfile



Relevant Pages