I want to search file for pattern, duplicate every line that matches that pattern, then in perform substitution on each duplicated line.
Suppose file looks like this:
a 1
a 2
b 1
b 2
c 1
c 2
I want to duplicate each line matching /2
, then substitute 2
with 3
(s/2/3
), and end up with file:
a 1
a 2
a 3
b 1
b 2
b 3
c 1
c 2
c 3