Tag Archives: defaults

How can I use defaults write with a multi-line value? [solved]

I’m trying to use defaults write com.myprogram.plist “dataName” “dataValue” It works fine, but I have a long string that I need to set as the value: TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNl Y3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gTWFlY2VuYXMg dGluY2lkdW50LCBkaWFtIHNlZCBtb2xlc3RpZSBsYW9y ZWV0LA== How can I do this from the command line? Do I use an escape character like “\n” or can I just read a value from a file directly with defaults write ? Solution / Answer Use /usr/libexec/PlistBuddy instead, its Import <entry> <file> should do exactly what you want. In defaults, you could try to hex-encode your data and use the -data argument as type.

Posted in Mac, Tech Tips | Tagged | Leave a comment