Replace (one or) two different patterns in a file with regexp
1
vote
4
answers
73
views
Suppose an
input.txt
file that contains several strings as the following ones:
[[foo>a|a]]
[[foo>b|b]]
[[foo>c|c]]
that I'd like to replace by:
:foo:a
:foo:b
:foo:c
I guess I could manage to achieve this result with sed
or rg
(I never used awk
).
But this file also contains other strings as the following ones:
[[foo>a|d]]
[[foo>b|e]]
[[foo>c|f]]
that I'd like to replace by:
:foo:d
:foo:e
:foo:f
All my attempts failed because I don't see how to handle two different patterns at once.
Do you know some ways to achieve the latter result (and, BTW, the former)?
Asked by Denis Bitouzé
(298 rep)
Dec 3, 2020, 03:12 PM
Last activity: Dec 3, 2020, 04:50 PM
Last activity: Dec 3, 2020, 04:50 PM