help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] How to replace a number of substrings simultaneously?


From: Peng Yu
Subject: Re: [Help-bash] How to replace a number of substrings simultaneously?
Date: Sat, 19 Oct 2019 21:57:31 -0500

How? I am replacing strings, not characters.

On Sat, Oct 19, 2019 at 9:49 PM Zephyr Waitzman <address@hidden> wrote:
>
> Using tr from coreutils?
>
> On Sunday, October 20, 2019, Peng Yu <address@hidden> wrote:
>>
>> Hi,
>>
>> I'd like to replace a number of substrings in a string simultaneously in 
>> bash.
>>
>> For example, replace "s1" by $s1, replace "s2" by $s2,...
>>
>> Something like this will not work robustly, because if $s1 is "s2",
>> then there will be two $s2 in the result.
>>
>> x=${x//s1/$s1}
>> x=${x//s2/$s2}
>>
>> It can be relatively easy to achieve this in other languages. But it
>> is not clear what might be the most succinct way to achieve it in
>> bash.
>>
>> Does anybody know? Thanks.
>>
>> --
>> Regards,
>> Peng
>>
>
>
> --
> GNU powered it...
> GPL protect it...
> GOD blessing it...
>
> Regards,
> Wi24rd 王滋涵



-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]