2017-06-20 36 views
0

我需要提取一個plist的一部分,將它存儲在一個文件中,然後將這個保存的部分加載/合併到另一個plist中,用其伴隨的鍵和值覆蓋現有的鍵。如何將plist的一部分存儲到文件中,然後將其合併到另一個plist中?

我明白PlistBuddy幫助的過程中顯着,你可以閱讀的部分通過其子項的關鍵: /usr/libexec/PlistBuddy -c "Print :KeyName" /path/to/some.plist

但是如果你可以簡單地使用文件重定向這裏保存輸出,然後重新裝入目前還不清楚它通過Merge命令與plist插入或不插入。

命令的例子將非常感謝!

回答

0

看來,以下過程可遵循修改plist出現合併值:

# Get contents that you want to store: 
/usr/libexec/PlistBuddy -x -c "Print :KeyYouWant" /path/to/plist_with_key_set_you_want.plist 

# Merge the contents of the saved file to the other plist: 
/usr/libexec/PlistBuddy -x -c "Merge plist_with_key_set_you_want.plist :KeyToMergeInto" /path/to/destination.plist 
相關問題