I'm trying to update a plist file using bash. For some strings I can update the plist file, but for some strings I get an error. For eg

defaults write '/Users/test/Desktop/myPlist'  'My Key' "[My Value]"

throws an error

2011-08-10 18:49:36.208 defaults[17287:903] Could not parse: [My Value].
Try single-quoting it.

Looks like the characters '[' and ']' seem to be throwing it off. How to make this work with the string "[My Value]"?

link|improve this question

71% accept rate
Maybe try single-quoting it...? – Wuffers Aug 11 '11 at 1:55
feedback

1 Answer

You could try single-quoting it, like this:

defaults write '/Users/test/Desktop/myPlist'  'My Key' "\"[My Value]\""
link|improve this answer
2011-08-10 19:05:44.531 defaults[17323:903] Could not parse: \'[My Value]\'. Try single-quoting it. Didnt work :( – smokinguns Aug 11 '11 at 2:02
This seemed to work: defaults write '/Users/test/Desktop/myPlist' 'My Key' "\"[My Value]\"" Wonder why? – smokinguns Aug 11 '11 at 2:04
Alright, will edit my answer. – Wuffers Aug 11 '11 at 2:12
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.