T.Souza
T.Souza

Reputation: 13

replacement with sed linux

I need to perform a replacement with sed in linux but it doesn't work.

from [$sonarqubeName] to [$projectName][$branchName]

I tried sed -i 's/[$projectName]/[$projectName][$branchName]/g'

sed -i 's/[$projectName]/[$projectName][$branchName]/g'

Upvotes: 1

Views: 34

Answers (1)

Alex Sveshnikov
Alex Sveshnikov

Reputation: 4339

The characters [, $, ] have special meaning inside the regular expressions (and some other characters as well, but they are not appearing in your search string). To use them as literal symbols you need to escape them with a backslash in the search expression. Try

sed -i 's/\[\$sonarqubeName\]/[$projectName][$branchName]/g'

Upvotes: 2

Related Questions