Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .