Home > Mobile >  replacement with sed linux
replacement with sed linux

Time:01-26

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'

CodePudding user response:

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'
  • Related