Replacing a variable string with the Groovy and SED command

I am trying to replace the entire description line contained in an XML file. I would like to replace this string with a variable. I am using the SED command in a Groovy script.

I have the following code. I expect the string "foo" to replace the description text, but it is not. Instead, the following line changes the XML: Description = "sDescription"

What am I doing wrong?

def sDescription = "foo"
def sedCommand = 'sed -i \'s/Description="[^"]*"/Description="'$sDescription'"/g\'  package.appxmanifest' as String
-2
source share
1 answer

Groovy / () . ('content') . , ("content"), , :

def sDescription = "foo"
def sedCommand = "sed -i 's/Description=\"[^\"]*\"/Description=\"$sDescription\"/g\'  package.appxmanifest" as String

, , . , (\) , .

: @tim_yates, , Groovy XML-, ?

+1

Source: https://habr.com/ru/post/1662451/


All Articles