Add a value to CustomPapers' plist using Terminal I'm trying to add a printer to CustomPapers' .plist using this terminal command:

defaults write com.apple.print.custompapers.plist 165x165 -dict-add &lt;bottom&gt;0&lt;/bottom&gt;&lt;custom&gt;1&lt;/custom&gt;&lt;height&gt;467.71653555&lt;/height&gt;&lt;id&gt;'165x165'&lt;/id&gt;&lt;left&gt;0&lt;/left&gt;&lt;name&gt;'165x165'&lt;/name&gt;&lt;printer&gt; &lt;/printer&gt;&lt;right&gt;0&lt;/right&gt;&lt;top&gt;0&lt;/top&gt;&lt;width&gt;467.71653555&lt;/width&gt;


Please can someone suggest where I've gone wrong with this and if a dictionary item exists with the key "165x165" that it should not add the item.
You have to quote the value, remove -dict-add, and use for example &lt;key&gt;name&lt;/key&gt;&lt;string&gt;165x165&lt;/string&gt; instead of &lt;name&gt;165x165&lt;/name&gt;:

defaults write com.apple.print.custompapers 165x165 '&lt;dict&gt;&lt;key&gt;bottom&lt;/key&gt;&lt;real&gt;0&lt;/real&gt;&lt;key&gt;custom&lt;/key&gt;&lt;true/&gt;&lt;key&gt;height&lt;/key&gt;&lt;real&gt;467.71653555&lt;/real&gt;&lt;key&gt;id&lt;/key&gt;&lt;string&gt;165x165&lt;/string&gt;&lt;key&gt;left&lt;/key&gt;&lt;real&gt;0&lt;/real&gt;&lt;key&gt;name&lt;/key&gt;&lt;string&gt;165x165&lt;/string&gt;&lt;key&gt;printer&lt;/key&gt;&lt;string&gt; &lt;/string&gt;&lt;key&gt;right&lt;/key&gt;&lt;real&gt;0&lt;/real&gt;&lt;key&gt;top&lt;/key&gt;&lt;real&gt;0&lt;/real&gt;&lt;key&gt;width&lt;/key&gt;&lt;real&gt;467.71653555&lt;/real&gt;&lt;/dict&gt;'

This checks if the key exists:

if defaults read com.apple.print.custompapers 165x165 &amp;&gt; /dev/null; then echo 'the key exists'; fi