相关疑难解决方法(0)

替换XML文件中的动态内容

快速摘要:我需要创建一个Bash脚本来每周自动更改节点中的文本.脚本将匹配节点并替换它们内部的文本(如果可能的话)?我该怎么做?

总结: 我主持一个拥有商店的Minecraft服务器,每个商店在/ ShowcaseStandalone/ffs-storage /目录中都有自己的.xml文件.每个星期天我的服务器重新启动并执行几个命令到终端重置几件事.我试图改变的一件事是商店之一.我想要更改节点<itemstack>中的文本和节点<price>中的文本.我只是想从不同文件夹中的.txt文件中获取文本,并将其插入到该节点中.问题是,节点中的文本每周都会更改.有没有办法用bash替换两个节点中的特定行或文本?

XML文件:

<?xml version="1.0" encoding="UTF-8"?>
<scs-shop usid="cac8480951254352116d5255e795006252d404d9" version="2" type="storage">
    <enchantments type="string"/>
    <owner type="string">Chadward27</owner>
    <world type="string">Frisnuk</world>
    <itemStack type="string">329:0</itemStack>
    <activity type="string">BUY</activity>
    <price type="double">55.0</price>
    <locX type="double">487.5</locX>
    <locY type="double">179.0</locY>
    <locZ type="double">-1084.5</locZ>
    <amount type="integer">0</amount>
    <maxAmount type="integer">0</maxAmount>
    <isUnlimited type="boolean">true</isUnlimited>
    <nbt-storage usid="23dffac5fb2ea7cfdcf0740159e881026fde4fa4" version="2" type="storage"/>
</scs-shop>
Run Code Online (Sandbox Code Playgroud)

操作系统: Linux Ubuntu 12.04

xml bash text replace dynamic

19
推荐指数
2
解决办法
2万
查看次数

标签 统计

bash ×1

dynamic ×1

replace ×1

text ×1

xml ×1