Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an iptables rule and I have to write a script that gets the numbers of packets and bytes target for that rule. I know that that command iptables -L -v -x shows that info, but I don't know how to extract it with a script.

It will be just a single rule in forward chain. Can somebody help me with this script? I have to show the answer on the console.

share|improve this question

1 Answer 1

You can simply redirect the answer in a file, using a command like this:

# iptables -L -v -x >> ~/iptable-stats.txt

Then, you can extract the right argument easier as it was shown on the prompt.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.