Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Thank you so much for your answer. I am now trying on my file, with the exact search and replace I need: xmlstarlet ed --var paths ‘//CS_CT[contains(text(), “། །”)]’ --update '$paths' -x 'substring-before(text(), “། །“)’ --subnode '$paths' -t elem -n ‘CS_NBSS’ -v ‘། །’ file_mod.xml But I have that shell error message: -bash: syntax error near unexpected token `(' I've checked carefully and believe I followed your syntax. Do you see anything wrong? I've tried with CSCT and CSNBSS, and replacing the Tibetan characters with letters, but still the error is the same Commented May 5, 2022 at 8:37
  • 1
    @Matt5 Your code in the comment does not use straight quotes (" and '), but typographical ("fancy") quotes as written by some word processors ( and ). This is going to cause issues in the shell. Commented May 5, 2022 at 8:39
  • It works! Thank you so much! Commented May 6, 2022 at 9:23
  • Sorry... I would like to know what would be your answer for an example searching every occurance of an example, that needs to be replaced by <b>a test</b> only if it is NOT within the <a> ... </a> tag (inside other tags): * Input example: xml <c>This is an example. <a>This is an example;</a></c> * Desired output: xml <c>This is <b>a test.</b> <a>This is an example;</a></c> Commented May 6, 2022 at 10:07
  • I have asked a related question in unix.stackexchange.com/q/701641/523366. Commented May 6, 2022 at 12:07