GNU bug report logs - #35020
I apologize it's not the right place, but I need answer

Previous Next

Package: sed;

Reported by: Budi <budikusasi <at> gmail.com>

Date: Wed, 27 Mar 2019 13:26:01 UTC

Severity: normal

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35020 in the body.
You can then email your comments to 35020 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#35020; Package sed. (Wed, 27 Mar 2019 13:26:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Budi <budikusasi <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Wed, 27 Mar 2019 13:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Budi <budikusasi <at> gmail.com>
To: bug-sed <at> gnu.org
Subject: Re: I apologize it's not the right place, but I need answer
Date: Wed, 27 Mar 2019 20:25:24 +0700
How can sed regex substitution replacement be the Hold space content ?
I do need the answer so really appreciate. Thanks much!

On 6/11/18, Budi <budikusasi <at> gmail.com> 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
>




Information forwarded to bug-sed <at> gnu.org:
bug#35020; Package sed. (Wed, 27 Mar 2019 22:24:01 GMT) Full text and rfc822 format available.

Message #8 received at 35020 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Budi <budikusasi <at> gmail.com>, 35020 <at> debbugs.gnu.org
Subject: Re: bug#35020: I apologize it's not the right place, but I need answer
Date: Wed, 27 Mar 2019 16:23:48 -0600
tags 35020
close  35020
stop

Hello,

On 2019-03-27 7:25 a.m., Budi wrote:
> How can sed regex substitution replacement be the Hold space content ?
> I do need the answer so really appreciate. Thanks much!

s/// command operate on the pattern space.
But you can use the 'x' command the exchange the content
of the hold and pattern space, and then use "s///".

Example:

This sed program accumulates even numbers
into the hold space (H), and prints the odd values (p).
At the end of the input ($), it fetches back the hold space content (x),
performs a regex substitution on it (s) and prints it (p).

$ seq 0 5 50 | sed -n '/0$/H;/5$/p;${x;s/\n/===/g;p}'
5
15
25
35
45
===0===10===20===30===40===50


regards,
 - assaf




bug closed, send any further explanations to 35020 <at> debbugs.gnu.org and Budi <budikusasi <at> gmail.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 27 Mar 2019 22:24:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-sed <at> gnu.org:
bug#35020; Package sed. (Thu, 28 Mar 2019 01:39:02 GMT) Full text and rfc822 format available.

Message #13 received at submit <at> debbugs.gnu.org (full text, mbox):

From: bill-auger <bill-auger <at> peers.community>
To: bug-sed <at> gnu.org
Subject: Re: bug#35020: I apologize it's not the right place, but I need answer
Date: Wed, 27 Mar 2019 21:35:10 -0400
On Wed, 27 Mar 2019 16:23:48 -0600 Assaf wrote:
> $ seq 0 5 50 | sed -n '/0$/H;/5$/p;${x;s/\n/===/g;p}'
> 5
> 15
> 25
> 35
> 45
> ===0===10===20===30===40===50

mmm, nerdelicious :)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Apr 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 362 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.