Skip to content

Instantly share code, notes, and snippets.

@larsks
Created November 4, 2012 17:29
Show Gist options
  • Save larsks/4012705 to your computer and use it in GitHub Desktop.
Save larsks/4012705 to your computer and use it in GitHub Desktop.
Parsing libvirt XML with GNU awk
@load "xml"
XMLSTARTELEM == "disk" {
in_disk=1
disk_file=""
disk_target=""
}
in_disk == 1 && XMLSTARTELEM == "source" {
disk_file=XMLATTR["file"]
}
in_disk == 1 && XMLSTARTELEM == "target" {
disk_target=XMLATTR["dev"]
}
XMLENDELEM == "disk" {
in_disk=0
print disk_target, disk_file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment