使用PlistBuddy(osx)在plist中查找条目
我试图在Mac计算机上找到当前用户是否启用了iCloud Documents。我找到了它所在的plist(MobileMeAccounts.plist),但是我可以使用plistbuddy语法的一些帮助来在树中定位。 这是我到目前为止的脚本的一部分: #!/bin/bash # Purpose: Grab iCloud Document Status plistBud="/usr/libexec/PlistBuddy" if [[ -e "/Users/*loggedInUser*/Library/Preferences/MobileMeAccounts.plist" ]]; then iCloudStatus=`$plistBud -c "print :Accounts:Services:MOBILE_DOCUMENTS" /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist` else iCloudDocuments="Not Enabled" fi echo "$iCloudStatus" 我特意寻找以下代码: <key>Enabled</key> <true/> 这是plist。如果向下滚动,您将看到启用它的“MOBILE_DOCUMENTS”: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Accounts</key> <array> <dict> <key>AccountAlternateDSID</key> <string>99999999</string> …