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
- Next message: Anil: "Re: Occurence of a string under a text block"
- Previous message: Paul Colquhoun: "Re: Yet another "stop the bash quoting" post"
- In reply to: Moran Levy: "how to use sed to replace a single occurrence in a file"
- Next in thread: Stephane CHAZELAS: "Re: how to use sed to replace a single occurrence in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Anil: "Re: Occurence of a string under a text block"
- Previous message: Paul Colquhoun: "Re: Yet another "stop the bash quoting" post"
- In reply to: Moran Levy: "how to use sed to replace a single occurrence in a file"
- Next in thread: Stephane CHAZELAS: "Re: how to use sed to replace a single occurrence in a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|