gpt4 book ai didi

macos - 如何使用 plutil 获取值?

转载 作者:行者123 更新时间:2023-12-02 15:56:03 26 4
gpt4 key购买 nike

我需要获取“ProductVersion”的值并输出:“15.1”我有 plutil 的版本,但无法获取值

plutil -key ProductVersion myfile//不工作

这是我的文件内容:

<?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>ProductVersion</key>
<string>15.1</string>
<key>SystemImageID</key>
<string>3DD7870B-96BB-4BA1-9C54-306734147FFE</string>
<key>Version</key>
<string>Version</string>
</dict>
</dict>
</plist>

plutil 的帮助:

-help                   Print this message
-full Print an exhaustive list of options
-verbose Show verbose output
-show Show property list data
-keys List top level dictionary keys
-create Create a new empty property list

-key keyname Recover value for key. Multiple uses builds keypath
-value value Set value for keypath
-remove Remove value at keypath
-type typeid Type to use while setting key. Valid types are int,
float, bool, json, and string (default). Use json to
define arrays and dictionaries
-convert format Convert each property list file to selected format.
Formats are xml1 and binary1 and json. Note that json
files are saved to filename.json

最佳答案

您的 plist 文件格式不正确;闭幕</dict>标签重复。这需要修复。

plutil macOS 12.3 附带的没有 -key选项(不再),但您可以使用 PlistBuddy :

/usr/libexec/PlistBuddy -c "Print :ProductVersion" myfile

关于macos - 如何使用 plutil 获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71523431/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com