Simple use of PlistBuddy, plistbuddy

Source: Internet
Author: User

Simple use of PlistBuddy, plistbuddy

 

Simple use of PlistBuddy

Since PlistBuddy is not in Mac's default Path, we need to reference this tool through the absolute Path:

  • View help
/usr/libexec/PlistBuddy --help
Let's take a look at PlistBuddy's simple print:
  • Initializes an info. plist file.

Initialize info. plist
  • Print the info. plist File
/usr/libexec/PlistBuddy -c "print" info.plist
  • Enter the preceding command on the terminal as follows:
Add
  • Add common fields:
/usr/libexec/PlistBuddy -c 'Add :Version string 1.0' info.plist
  • Add an array field in two steps. Note:Keys are separated by: And no space is allowed.:
# First Add the key value/usr/libexec/PlistBuddy-c 'add: Application array 'info. plist # Add value yans67deMacBook-Pro: needfiles huangyg $/usr/libexec/PlistBuddy-c 'add: Application: string app1' info. plistyans67deMacBook-Pro: needfiles huangyg $/usr/libexec/PlistBuddy-c 'add: Application: string app2' info. plistyans67deMacBook-Pro: needfiles huangyg $/usr/libexec/PlistBuddy-c 'add: Application: string app3' info. plist
  • Add a dictionary field in two steps:
# First Add the key value/usr/libexec/PlistBuddy-c 'add: Person dict 'info. plist # Add value,/usr/libexec/PlistBuddy-c 'add: Age string secret 'info. plist/usr/libexec/PlistBuddy-c 'add: Person: Name string yans67 'info. plist/usr/libexec/PlistBuddy-c 'add: Person: sex string boy 'info. plist/usr/libexec/PlistBuddy-c 'add: Person: weight string 65'info. plist
Output
  • Print the corresponding field value:
 /usr/libexec/PlistBuddy -c 'Print :Person' info.plist
  • In array, we can also print a specific value according to the subscript.
/usr/libexec/PlistBuddy -c 'Print :Application:2' info.plist
Delete
  • Delete the corresponding field value:
/usr/libexec/PlistBuddy -c 'Delete :Version' info.plist
Modify
  • Modify the value of a field:
/usr/libexec/PlistBuddy -c 'Set :Application:1 string "thi is app1"' info.plist
Merge
  • When there are two plist files, we can merge them.
# Merge A. plist into B. plist/usr/libexec/PlistBuddy-c 'merge A. plist' B. plist

The terminal will prompt that B. plist has duplicate key values, so the merge of this key value is skipped by default.
Before merging

Link: http://www.jianshu.com/p/2167f755c47e

Reference link: http://shaojunxiao.com/#/03/23/use plistbuddyto modify the info-plistfile /? Utm_source = tuicool & utm_medium = referral

Https://segmentfault.com/a/1190000002423661

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.