find with logic AND

Hello people, i have a list of dhcp-client interfaces

wan1 bound comment balanced
wan2 bound comment balanced
wan3 bound comment balanced
wan4 bound comment balanced
wan5 bound comment balanced
wan6 bound comment balanced
wan7 bound comment admin

there is a way to ([find status = “bound”] and comment~“balanced”)in the same statement?

i need to get the name of the interface that meet the two conditions

thanks

Yes. And it is quite literally using the word “and”, i.e.

[find status = "bound" and comment~"balanced"]

You can also use the “&&” as an equivalent to “and”, if you’re more accustomed to that from programming languages.

this is so shameful for me, i hace experience in some programming languages, routers included, and when i post some question it’s because i’ve tried everything, last night i try a lot of times this

:foreach iface in=[/ip dhcp-client find comment~"balance" && status="bound"] do={ 
   :set ifname ([/ip dhcp-client get $iface interface]);
   :log info $ifname;
};

but doesn’t work, but now it works normal, maybe i was so tired and have some typo error, thanks a lot.

If you’re trying to get stuff out of those matches (as opposed to, let’s say, remove all of them), it’s more efficient to use “print as-value”, e.g.

:foreach iface in=[/ip dhcp-client print as-value where comment~"balance" && status="bound"] do={ 
   :log info ($iface->"interface");
};

ok bro, i will try that, thanks a lot.