[SOLVED] How to iterate only through interfaces that have a comment set?

Hi,

I need a little help here - how to iterate through the list of interfaces that have a comment set?

Here’s the list of interfaces I use for testing on an RB2011:

[admin@MikroTik] > interface print
Flags: D - dynamic, X - disabled, R - running, 
S - slave 
 #     NAME                                TYPE      
 0     ether1-gateway                      ether     
 1  RS ;;; test123
       ether2                              ether     
 2   S ether3                              ether     
 3   S ether4                              ether     
 4   S ether5                              ether     
 5   S ether6-master-local                 ether     
 6   S ether7-slave-local                  ether     
 7   S ether8-slave-local                  ether     
 8   S ether9-slave-local                  ether     
 9   S ether10-slave-local                 ether     
10   S sfp1                                ether     
11  R  bridge-local                        bridge

Trying to iterate only through interfaces that have a comment set:

[admin@MikroTik] > :foreach IF in=[/interface ethernet find where comment] do={ put $IF };

Using the negation operator I can at least get a list of interfaces which do not have any comment set:

[admin@MikroTik] > :foreach IF in=[/interface ethernet find where !comment] do={ put $IF };
*2 
*4
*5
*6
*7
*8
*9
*a
*b
*1

The expected result is to list only ether2 as it is the only interface with a comment.

Thanks

Since recent versions, I think you need to use “any”, i.e.

find where any comment

Yes, that works. Thanks! Seems like the scripting guide in the wiki could use a little updating.

I wonder where is documentation for this, can Mikrotik enlighten me?

It’s in the change logs for 6.19, and only there for now.