【问题标题】:space character between quotes in bash script using XMLStarlet使用 XMLStarlet 的 bash 脚本中引号之间的空格字符
【发布时间】:2017-08-06 13:22:23
【问题描述】:

我正在尝试使用 XMLStarlet 工具在 bash 中使用脚本编辑我的 xml 文件。 所以我想删除我的文件的完整标签,我的问题在于我的命令语法如下:

xmlstarlet ed -d "/properties/structure name=\"preference\"" $1

标签是structure name="preference" >

我的错误是: XPath 错误:无效的表达式 /properties/structure" "name="preference" 错误指向第一个引号 (")

我尝试插入引号、反斜杠以使空格字符可以接受,但我找不到使它起作用的方法。 有人可以帮我解决这个问题吗?我还没有找到谈论这个的话题。

提前致谢

【问题讨论】:

  • 能否提供完整的XMLsn-p?

标签: xml bash shell space xmlstarlet


【解决方案1】:

发件人:

<properties>
    <bla name="preference" >
    </bla>
    <structure name="preference" >
    </structure>
    <structure name="xxx" >
    </structure>
</properties>

xmlstarlet ed -d '/properties/structure[@name="preference"]'

生产

<?xml version="1.0"?>
<properties>
  <bla name="preference">
    </bla>
  <structure name="xxx">
    </structure>
</properties>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-15
    • 2012-05-30
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 2019-10-08
    相关资源
    最近更新 更多