How could I insert
/foo/ after and only after opening brackets?
(/baz/bar) should not become
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
A convoluted way, assuming that you want to add
/foo/ to any pattern between parenthesis:
$ echo '(bar)' | sed 's;(/*\([^(]*\);(/foo/\1;' (/foo/bar) $ echo '(/bar/baz)' | sed 's;(/*\([^(]*\);(/foo/\1;' (/foo/bar/baz)
The command says:
Select what is between parenthesis and capture it, (could begin with a slash
/), and replace
/foo/ and the captured pattern.