Hello kiloman,
This feels like homework, so I'll just point you in the general direction
There are several ways to do this.
You could do it all in Perl, or you could do it just from a command prompt.
If you went down the command prompt route, you can join every other line using 'sed':
Code:
$ /your/iptables/command --andopts | sed '$!N;s/\n/ /'
You could then pipe this output through 'awk' and just output the fields you want:
Code:
$ /your/iptables/command --andopts | sed '$!N;s/\n/ /' | awk 'BEGIN { print "IP downloaded-bytes uploaded-bytes" } { print $1 " " $2 " " $3 }'
(the positional parameters used above ($1, $2 and $3) would need setting to whatever field you required, based on the output of the first command)
This code presumes that your iptables command only shows you the data, and there are no column names or other identifiers in the mix. I don't use iptables, so I'm not familiar with the layout.
Good luck!