[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35020: I apologize it's not the right place, but I need answer
From: |
Assaf Gordon |
Subject: |
bug#35020: I apologize it's not the right place, but I need answer |
Date: |
Wed, 27 Mar 2019 16:23:48 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 |
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