Reading and modify OS X plist file by command line

来源:互联网 发布:中国经济现状数据 编辑:程序博客网 时间:2024/05/16 09:12
OS X uses plist file to store configuration information.
1. to read a plist can use:<span style="white-space:pre"></span>sudo defaults read /Library/Preferences/com.apple.CrashReporter
2. and similarly to write a value to a plist<span style="white-space:pre"></span>sudo defaults write /Library/Preferences/com.apple.CrashReporter SomeKey -bool TRUE
<span style="white-space:pre"></span>sudo defaults write /Library/Preferences/com.apple.CrashReporter SomeKey -string "somevalue"3. and delete<span style="white-space:pre"></span>sudo defaults delete /Library/Preferences/com.apple.CrashReporter SomeKey
You can also use plutil to dump an XML version to stdout:<span style="white-space:pre"></span>plutil -convert xml1 -o - filename.plist
as well as convert between binary and XML formats. Xcode also ships with a plist editor (standalone prior to XCode 4, built-in since then).And if that wasn't enough there's also PlistBuddy, here's an example command to print a particular key 'BluetoothVersionNumber':
/usr/local/bin/PlistBuddy -c Print:BluetoothVersionNumber /Library/Preferences/com.apple.Bluetooth.plist


0 0
原创粉丝点击