1
votes

I'd to know how to delete a node with range using the command below.

single node delete works fine:

xmlstarlet ed -L -d '//job/input/audio_selector[2]' profile.xml

How to achieve this if I want to delete a node with range.

sample delete a node audio_selector from range 2 to 20:

1
Your current xpath is deleting the audio_selector based on position; it's deleting the second audio_selector. Is this what you really want or do you want to base it on the value of audio_selector?Daniel Haley

1 Answers

1
votes

If you're trying to delete the audio_selector based on position, try:

xmlstarlet ed -L -d '//job/input/audio_selector[position() >= 2 and 20 >= position()]' profile.xml

If you're trying to delete the audio_selector based on value, try:

xmlstarlet ed -L -d '//job/input/audio_selector[number() >= 2 and 20 >= number()]' profile.xml