Subject: Re: bug#31781: I apologize it's not the right place, but I need answer

From: Assaf Gordon <[email-masked]>
Date: Tue, 12 Jun 2018 03:04:21 -0600

tags 31781 notabug
close 31781
stop

Hello,

On 10/06/18 04:58 PM, Budi wrote:
> ​How to use SED command(s) that will replace the shell's pipe command in
> order to perform more efficient, e.g:
> 
> echo abcde​ | sed -r 's/cd/XX/' | sed 's/[^x]/z/ig'
> 
> become far more efficient and compact, might be look like this,
> 
> echo abcde​ | sed -r 's/cd/XX/ {N: s/ ...........    }
> 
> ( ...so on. That's what I am asking for )
> 
> both will give the same result   zzXXz
> 

The portable way is to use multiple "-e" parameters:

   $ echo abcde​ | sed -e 's/cd/XX/' -e 's/[^x]/z/ig'
   zzXXzz

That should work on all sed, not just gnu sed.

When using GNU sed, you can specify multiple commands
separated by semicolons:

   $ echo abcde​ | sed 's/cd/XX/ ;  s/[^x]/z/ig'
   zzXXzz

I'm closing this item but discussion can continue by replying
to this thread.

regards,
  - assaf