Is there a way for sed
to pipe a capture group to another program, making \1
in the regexp's RHS equal to the output of that program?
For example, running
sed 's/lorem ipsum \(foobar\)/\1/g' file.txt
would pipe "foobar" through another program (e.g., tr 'o' 'a'
) to make \1
be "faabar" for sed
to replace "lorem ipsum foobar" with "lorem ipsum faabar"?
This is just a simple example. I realize I could convert "foobar" to "faabar" without using tr
.