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.

Full log


Message #10 received at control <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




This bug report was last modified 6 years and 53 days ago.

Previous Next


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