我需要獲取“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
uj5u.com熱心網友回復:
您的 plist 檔案格式錯誤;結束</dict>標簽重復。這需要修復。
plutilmacOS 12.3 附帶的沒有-key選項(不再),但您可以使用PlistBuddy:
/usr/libexec/PlistBuddy -c "Print :ProductVersion" myfile
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/447174.html
下一篇:如何在C中洗掉對變數的參考
