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:


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.

Related Posts:

  • No Related Posts
This entry was posted in Mac, Tech Tips and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *