Find returns wrong result

Hi,

could someone please explain me how to write this so it is working properly?

[admin@MikroTik] > :local name 11; :put [ /interface eoip find name="$name" ]
*c;*12
[admin@MikroTik] > :put [ /interface eoip find name="11" ]

I am trying to write a simple script, but realized that it is not working properly and find returns all records instead of the one with that name.
I thought this has something to do with the variable scopes? but even setting the vars as global didnt help nor I am able to write it in a way so it would work.

Thank you for your help.

The variable name of “name” is causing an ambiguity in the parsing. Try the following instead:

:local x 11; :put [ /interface eoip find name="$x" ]

To explain more, because you used “name” as the variable, your comparison is really, “where name=name”. In other words, the “$name” is the interface name and the interface name always equals the interface name.

Thank you VERY MUCH. It is working now