【问题标题】:How to use plutil to replace data into a .plist file如何使用 plutil 将数据替换为 .plist 文件
【发布时间】:2021-10-06 12:35:40
【问题描述】:

我有 1 个文件 test.plist:

我想用我上面一些文件的值替换AccountToken键

AccountToken=$(cat AccountToken.txt)

我尝试了这个命令,但它不起作用

plutil -key AccountToken -string $AccountToken test.plist

输出:

<key>AccountToken</key>
    <string>
W50ZXJuYXRpb25hbE1vYmlsZUVx
</string>

我想要 2 个关键字符串 ==> 数据

请帮忙,谢谢大家!!

【问题讨论】:

    标签: bash replace find command key


    【解决方案1】:

    Editing Property Lists with plutil。替换密钥的选项是-replace,而不是-key

    plutil -replace AccountToken -string "$AccountToken" test.plist
    

    【讨论】:

    • 这是最后添加的结果1个新值,上面保持不变:replaceeyAiSW50ZXJuYXRpb25hbE1vYmlsZUVxdWlwbWVudElk
    • 如果你使用-replace replace而不是-replace AccountToken会发生这种情况
    猜你喜欢
    • 2018-01-30
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    相关资源
    最近更新 更多