Skip to content

Instantly share code, notes, and snippets.

@Pephers
Last active November 27, 2016 16:11
Show Gist options
  • Save Pephers/5773393 to your computer and use it in GitHub Desktop.
Save Pephers/5773393 to your computer and use it in GitHub Desktop.
Update and delete nodes in many XML files
# delete node
find . -name modules.xml | xargs xmlstarlet ed -L -d '//node'
# update attribute
find . -name modules.xml | xargs xmlstarlet ed -L -u '//node/@attr' -v 'value'
# indent with 4 spaces
for i in $(find . -name 'modules.xml'); do xmlstarlet fo -s 4 "$i" > "$i.tmp"; mv "$i.tmp" "$i"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment