I have the following xml. I need to extract the IP address, protocol and port into a CSV file with the corresponding column names.
<rule family="ipv4">
<source address="10.XXX.XX.XX"/>
<port protocol="tcp" port="22"/>
<log prefix="ber_" level="warning">
<limit value="1/m"/>
</log>
<accept/>
</rule>
<rule family="ipv4">
<source address="10.XXX.XX.XXX"/>
<port protocol="udp" port="1025"/>
<log prefix="ber_" level="warning">
<limit value="1/m"/>
</log>
<accept/>
I'm able to grep IP address or the port using grep or sed like this grep -Eo "([0-9]{1,3}[\.]){3}[0-9]{1,3}"
But I need it as columns in CSV file.
IPAddress Protocol Port . What is the best way to achieve this?