一般我们编辑plist文件都是直接打开,用PlistEditor什么的进行可视化编辑,但是如果想用脚本编辑plist文件就要用到命令行了,其实这是一个很简单的命令:defaults
defaults 命令的帮助如下
'defaults' [-currentHost | -host ] followed by one of the following:
read shows all defaults
read shows defaults for given domain
read shows defaults for given domain, key
read-type shows the type for the given domain, key
write writes domain (overwrites existing)
write writes key for domain
rename
renames old_key to new_key
delete deletes domain
delete deletes key in domain
domains lists all domains
find lists all entries containing word
help print this help
is ( | -app | -globalDomain )
or a path to a file omitting the '.plist' extension
is one of:
-string
-data
-int[eger]
-float
-bool[ean] (true | false | yes | no)
-date
-array ...
-array-add ...
-dict ...
-dict-add …
光看这些就大概知道怎么弄了吧,下面是几个例子:
defaults read com.xxx.xxx // 输出文件中所有信息
defaults write com.xxx.xxx // 改变某个key的value,如果没有该key则添�
注意:在 "com.xxx.xxx" 之后没有 ".plist",开始我犯了这个错误,弄半天不知道为何plist文件中的值没有改变。
(END)