Skip to content

Instantly share code, notes, and snippets.

@domcleal
Last active April 20, 2017 11:59
Show Gist options
  • Save domcleal/cef784d59cf6f4835ae45065918229c8 to your computer and use it in GitHub Desktop.
Save domcleal/cef784d59cf6f4835ae45065918229c8 to your computer and use it in GitHub Desktop.
Copy part of an Augeas XML tree into another file
#!/bin/bash
orig=$PWD/original.xml
new=$PWD/output.xml
rm -f $new
augtool -s -e -t "Xml incl $orig" -t "Xml incl $new" <<EOF
cp /files$orig/xml/Child[2]/ChildOfChild/Child /files$new/VirtualHost/Child
EOF
cat $new
<xml>
<Child></Child>
<Child> <ChildOfChild> <Child>
<Directory foo="bar" />
<Foo>bar</Foo>
</Child> </ChildOfChild> </Child>
</xml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment