Skip to content

Instantly share code, notes, and snippets.

@doxt3r
Forked from Pephers/xmlstarlet-snippets.sh
Created November 27, 2016 16:11
Show Gist options
  • Save doxt3r/bade6c8d8ed0549e32d72775269084ba to your computer and use it in GitHub Desktop.
Save doxt3r/bade6c8d8ed0549e32d72775269084ba 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