Don't display chains with no matched entries when -b

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-10-22 14:15:37 -07:00
parent 59a75512be
commit f24e194819
5 changed files with 24 additions and 19 deletions

View File

@ -678,7 +678,12 @@ show_command() {
# eliminates rules which have not been used from ip*tables' output # eliminates rules which have not been used from ip*tables' output
brief_output() { brief_output() {
grep -Eve '^ +0 +0 +' awk \
'/^Chain / { heading1 = $0; getline heading2; printed = 0; next; };
/^ +0 +0 / { next; };
/^$/ { if ( printed == 1 ) { print $0; }; next; };
{ if ( printed == 0 ) { print heading1; print heading2; printed = 1 }; };
{ print; }';
} }
while [ $finished -eq 0 -a $# -gt 0 ]; do while [ $finished -eq 0 -a $# -gt 0 ]; do

View File

@ -843,11 +843,11 @@
Netfilter table to display. The default is <emphasis Netfilter table to display. The default is <emphasis
role="bold">filter</emphasis>.</para> role="bold">filter</emphasis>.</para>
<para>The <emphasis role="bold">-b</emphasis> ('brief') <para>The <emphasis role="bold">-b</emphasis> ('brief') option
option causes rules which have not been used (i.e. which causes rules which have not been used (i.e. which have zero
have zero packet and byte counts) to be omitted from the packet and byte counts) to be omitted from the output. Chains
output. In the future, this may be extended to omit unused with no rules displayed are also omitted from the
chains entirely.</para> output.</para>
<para>The <emphasis role="bold">-l</emphasis> option causes <para>The <emphasis role="bold">-l</emphasis> option causes
the rule number for each Netfilter rule to be the rule number for each Netfilter rule to be

View File

@ -1398,9 +1398,9 @@
<para>The <emphasis role="bold">-b</emphasis> ('brief') option <para>The <emphasis role="bold">-b</emphasis> ('brief') option
causes rules which have not been used (i.e. which have zero causes rules which have not been used (i.e. which have zero
packet and byte counts) to be omitted from the output. In the packet and byte counts) to be omitted from the output. Chains
future, this may be extended to omit unused chains with no rules displayed are also omitted from the
entirely.</para> output.</para>
<para>The <emphasis role="bold">-l</emphasis> option causes <para>The <emphasis role="bold">-l</emphasis> option causes
the rule number for each Netfilter rule to be the rule number for each Netfilter rule to be

View File

@ -841,11 +841,11 @@
Netfilter table to display. The default is <emphasis Netfilter table to display. The default is <emphasis
role="bold">filter</emphasis>.</para> role="bold">filter</emphasis>.</para>
<para>The <emphasis role="bold">-b</emphasis> ('brief') <para>The <emphasis role="bold">-b</emphasis> ('brief') option
option causes rules which have not been used (i.e. which causes rules which have not been used (i.e. which have zero
have zero packet and byte counts) to be omitted from the packet and byte counts) to be omitted from the output. Chains
output. In the future, this may be extended to omit unused with no rules displayed are also omitted from the
chains entirely.</para> output.</para>
<para>The <emphasis role="bold">-l</emphasis> option causes <para>The <emphasis role="bold">-l</emphasis> option causes
the rule number for each Netfilter rule to be the rule number for each Netfilter rule to be

View File

@ -1277,11 +1277,11 @@
Netfilter table to display. The default is <emphasis Netfilter table to display. The default is <emphasis
role="bold">filter</emphasis>.</para> role="bold">filter</emphasis>.</para>
<para>The <emphasis role="bold">-b</emphasis> ('brief') <para>The <emphasis role="bold">-b</emphasis> ('brief') option
option causes rules which have not been used (i.e. which causes rules which have not been used (i.e. which have zero
have zero packet and byte counts) to be omitted from the packet and byte counts) to be omitted from the output. Chains
output. In the future, this may be extended to omit unused with no rules displayed are also omitted from the
chains entirely.</para> output.</para>
<para>The <emphasis role="bold">-l</emphasis> option causes <para>The <emphasis role="bold">-l</emphasis> option causes
the rule number for each Netfilter rule to be the rule number for each Netfilter rule to be