Created
November 4, 2012 17:29
-
-
Save larsks/4012705 to your computer and use it in GitHub Desktop.
Parsing libvirt XML with GNU awk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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