?xml version="1.0"?> <system> <machine name="web01" > <server name="log_collect"> <processes>1</processes> <threads>1</threads> <options>-t1 </options> <desc/> </server> <server name="dcs_fresh"> <processes>1</processes> <threads>1</threads> <options>-a192.168.1.1</options> <desc/> </server> </machine> <machine name="web02"> <server name="log_collect"> <processes>2</processes> <threads>2</threads> <options>-t2 </options> <desc/> </server> <server name="dcs_fresh"> <processes>2</processes> <threads>2</threads> <options>-a192.168.1.2</options> <desc/> </server> </machine>
BEGIN{FS="[<>/"]"} /machine name/{a=$3} /server name/{b=$3} />.*</{c=c?c" "$3:$3} /<//server>/{print a" "b" "c;b=0;c=0}
[[email protected]:~/shell/monitor]>>awk -f xml.awk xml web01 log_collect 1 1 -t1 web01 dcs_fresh 1 1 -a192.168.1.1 web02 log_collect 2 2 -t2 web02 dcs_fresh 2 2 -a192.168.1.2
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/2478.html