Re: how to use sed to replace a single occurrence in a file
From: Andrew Tkachenko (pobugfix_at_peterlink.ru)
Date: 11/28/04
- Next message: Alex Hunsley: "Re: using redirection (>) as part of an exec using find"
- Previous message: Moran Levy: "how to use sed to replace a single occurrence in a file"
- In reply to: Moran Levy: "how to use sed to replace a single occurrence in a file"
- Next in thread: Bill Marcum: "Re: how to use sed to replace a single occurrence in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Alex Hunsley: "Re: using redirection (>) as part of an exec using find"
- Previous message: Moran Levy: "how to use sed to replace a single occurrence in a file"
- In reply to: Moran Levy: "how to use sed to replace a single occurrence in a file"
- Next in thread: Bill Marcum: "Re: how to use sed to replace a single occurrence in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]