Issue
I'm trying to access a specific property in a plist
file on my MAC OS, but the name of that property has a space in it and I cannot access it.
here is the request that I try but it returns me all SpacesDisplayConfiguration
:
$defaults read com.apple.spaces SpacesDisplayConfiguration Space\ Properties
I think that this is just a syntax error, but I can't find the issue.
Solution
If you like doing ugly things, you could do something really ugly like this:
defaults read com.apple.spaces > /tmp/$$.plist
/usr/libexec/PlistBuddy -c 'print :SpacesDisplayConfiguration:Space\ Properties' /tmp/$$.plist
Though this is maybe slightly less ugly:
/usr/libexec/PlistBuddy -c 'print SpacesDisplayConfiguration:Space\ Properties' $HOME/Library/Preferences/com.apple.spaces.plist
The following attempts don't work, and if anyone knows why they can maybe ping me - I presume it has to do with bash
process substitutions not being seekable.
defaults read com.apple.spaces | /usr/libexec/PlistBuddy -c 'print :SpacesDisplayConfiguration:Space\ Properties' /dev/stdin
defaults read com.apple.spaces | /usr/libexec/PlistBuddy -c 'print :SpacesDisplayConfiguration:Space\ Properties' -
/usr/libexec/PlistBuddy -c "print" <(defaults read com.apple.spaces)
Answered By - Mark Setchell Answer Checked By - Pedro (WPSolving Volunteer)