I want to use perl to replace a key-value pair in an xml file, but I am having problems escaping the xml from the regex parser. All this is supposed to run from a bash script. So I have two variables:
macDefault="<key>DefaultVolume</key>\
<string>91630106-4A1F-4C58-81E9-D51877DE2EAB</string>"
winDefault="<key>DefaultVolume</key>\
<string>EBD0A8B3-EE3D-427F-9A83-099C37A90556</string>"
And I want perl to replace the occurrence of the value $macDefault with the value of $winDefault in the file config.plist
Unfortunately
perl -0pe 's/'"$macDefault"'/'"$winDefault"'/' config.plist
does not work, as perl reports:
Having no space between pattern and following word is deprecated at -e line 1.
Bareword found where operator expected at -e line 1, near "s/<key>DefaultVolume</key> <string>91630106-4A1F-4C58-81E9-D51877DE2EAB</string"
Having no space between pattern and following word is deprecated at -e line 1.
Bareword found where operator expected at -e line 1, near "<string>EBD0A8B3"
(Missing operator before EBD0A8B3?)
Bareword found where operator expected at -e line 1, near "427F"
(Missing operator before F?)
Bareword found where operator expected at -e line 1, near "9A83"
(Missing operator before A83?)
Bareword found where operator expected at -e line 1, near "099C37A90556"
(Missing operator before C37A90556?)
syntax error at -e line 1, near "s/<key>DefaultVolume</key> <string>91630106-4A1F-4C58-81E9-D51877DE2EAB</string"
Illegal octal digit '9' at -e line 1, at end of line
Illegal octal digit '9' at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
Thanks for any help!
Aucun commentaire:
Enregistrer un commentaire