【发布时间】:2012-11-02 10:11:06
【问题描述】:
快速总结:我需要创建一个 Bash 脚本来每周自动更改节点内的文本。脚本将匹配节点并替换其中的文本(如果可能的话)?我该怎么做?
总结:
我托管了一个包含商店的 Minecraft 服务器,每个商店在 /ShowcaseStandalone/ffs-storage/ 目录中都有自己的 .xml 文件。每个星期天我的服务器都会重新启动并在终端中执行几个命令来重置一些东西。我想要改变的一件事是其中一家商店。我想更改节点
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>
操作系统: Linux Ubuntu 12.04
【问题讨论】:
-
所以你只是想从 scs-shop 标签更改 usid ?
-
XML 操作仅使用
bash?为什么要限制自己? -
@sputnick 抱歉,我不得不添加 < 和 > 标签,因为它杀死了我的节点,但是不,我需要替换节点“itemstack”和“price”中的文本
-
@Brian-Cain 有没有其他方法可以从终端执行此操作?因为这些命令都是在服务器关闭时执行的
-
我推荐python——你的服务器是否安装了python,或者可以吗?如果没有,java 可能是另一种选择。
标签: xml bash dynamic text replace