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

From: Andrew Tkachenko (pobugfix_at_peterlink.ru)
Date: 11/28/04


Date: Sun, 28 Nov 2004 21:46:48 +0000

Moran Levy wrote on 28 Ноябрь 2004 17:50:

> 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
> The output should be:
>
> 9999
> 5678
> 1234
> 5678
> 1234
>
> Thank you for your help

there is a good sed-faq:
http://www.faqs.org/faqs/editor-faq/sed/

check out "4.3. How do I change only the first occurrence of a pattern?".
This is what you are loking for.

-- 
Andrew