title: Iptables remove specific rules by comment
body: <p>I need to delete some rules with same comment.</p>
  
  <p>For example I have rules with comment = "test it", so i can get list of them like this:</p>
  
  <pre><code>sudo iptables -t nat -L | grep 'test it'
  </code></pre>
  
  <p>But how can i delete all PREROUTING rules with comment 'test it'?</p>
  
  <p><strong>UPD:</strong>
  As @hek2mgl said, i can do something like this:</p>
  
  <pre><code>sudo bash -c "iptables-save &gt; iptables.backup"
  sed -i '/PREROUTING.*--comment.* "test it"/d' iptables.backup
  sudo iptables-restore &lt; iptables.backup
  sudo rm iptables.backup
  </code></pre>
  
  <p>But between save and restore could be changes in iptables, so after restore there will be problems =/</p>