首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用plistbuddy访问值

无法使用plistbuddy访问值
EN

Stack Overflow用户
提问于 2022-06-11 18:15:22
回答 1查看 66关注 0票数 0

我试图从AccountID "/Library/Preferences/MobileMeAccounts.plist“中的MobileMeAccounts plist中读取键”macOS“的值,并得到错误:

代码语言:javascript
复制
/usr/libexec/PlistBuddy -c "print :Accounts:AccountID" /Users/username/Library/Preferences/MobileMeAccounts.plist

错误:“打印:条目”:“帐户:AccountID”,不存在“

如果我向上移动一个节点,下面是输出的一个片段:

代码语言:javascript
复制
/usr/libexec/PlistBuddy -c "print :Accounts" /Users/username/Library/Preferences/MobileMeAccounts.plist

输出:

代码语言:javascript
复制
<?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>Accounts</key>
    <array>
        <dict>
            <key>AccountAlternateDSID</key>
                <string>b95dc8b6-8ec4-4644-ade8-ca8e3eeb1f82</string>
            <key>AccountDSID</key>
                <string>12345678901</string>
            <key>AccountDescription</key>
                <string>iCloud</string>
            <key>AccountID</key>
                <string>username@domain.com</string> * * * * * * * * * * * How do I access this value?
            <key>DisplayName</key>
                <string>firstName lastName</string>
            <key>LoggedIn</key>
                <true/>
            <key>Services</key>
            <array>

在这个例子中,为了输出"username@domain.com“,我似乎不知道我遗漏了什么简单的东西。

EN

回答 1

Stack Overflow用户

发布于 2022-06-12 02:07:45

正如Gordon Davisson指出的那样:"Accounts包含一个数组,您需要指定您想要的数组的哪个元素。尝试打印:Accounts:0:AccountID。“

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72586848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档