Fix regex to match format of iptables-save from iptables >= 1.4.15 cleanup_rules.awk optimizes the set of rules from iptables-save output. In iptables < 1.4.15 the lines with these rules contains a trailing space, in iptables >= 1.4.15 that trailing space is ommited. --- src/cleanup_rules.awk +++ src/cleanup_rules.awk @@ -43,11 +43,11 @@ function scan_rule(string, chain = substr(string, RSTART, RLENGTH); spec_start = RLENGTH+2; - if ( match(string, "-j[ ][a-zA-Z0-9_+]+.*") == 0) { + if ( match(string, "-j[ ][a-zA-Z0-9_+]+.*[^ ]") == 0) { printf("Rule with no target: -A %s %s\n", chain, specification); return; } - target = substr(string, RSTART+3, RLENGTH-4); + target = substr(string, RSTART+3, RLENGTH-3); specification = substr(string, spec_start, length(string) - spec_start - (RLENGTH)); if ( specification == "" && target == "" ) {