logo       

Re: Post-grep-like operations: msg#00045

editors.sed.user

Subject: Re: Post-grep-like operations

I always use the following approach in this situation, even
though better sedders than me don't seem to like it. It
uses the t and b branch commands following a subsitution. I
like it because it is simple and works well with a negative
or a postive match, and, I don't have to fuss trying to
use the special character "!" in a script or on the commandline.

eg.

s/fruit/fruit/
t fruit
s/veg/veg/
t veg
b
:fruit
Put your subsitution command here
b
: veg
Put your subsitution command here


On Sat, Dec 10, 2005 at 04:31:20PM +0000, Rob Simpson wrote:
>
> I am wanting to select lines containing 'fruit' or 'veg', and then carry out
> some operation on them, say substitution X for a.
>
> Eg.
>
> fruit banana
> fruit fly
> meat beef
> veg carrot
>
> to
>
> fruit bXnXnX
> fruit fly
> veg cXrrot
>
> I am trying to do this in a sed file:
>
> /fruit/b
> /veg/b
> d
> s/a/X/g
>
> using the grep like command in the one-liners document.
>
> The last expression doesn't get carried out. I guess something is happening
> with the buffer, but do not understand what. I can't find '/b' in the
> documentation.
>
> I am trying to avoid having to do multiple passes of the data, but maybe I
> can't.
>
> Any help much appreciated,
>
> Rob
>
>
>
>
>
> --
>
> Yahoo! Groups Links
>
>
>
>
>
>


------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/TtwFAA/dkFolB/TM
--------------------------------------------------------------------~->

--

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/

<*> To unsubscribe from this group, send an email to:
sed-users-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise