The full tutorial is the manual, but the TL;DR is:
:find can be used to find a position of an element in an array or a position of a substring in a string: :local myArray {“127”;“226”;“313”} ; put [:find $myArray “226” 0] ; put ($myArray->1)
1
226 :local myString “abcdef” ; :put [:find $myString “cde” 0]
2
find can be used to create a list of internal IDs of configuration items of the same type that match the condition expression following the find keyword: /ip/address/print ; /ip/address {:put [find where interface=ether2] ; :foreach addr in=[find where interface=ether2] do={:put [get $addr network]}}
Flags: D - DYNAMIC
Columns: ADDRESS, NETWORK, INTERFACE
As noted, it’s really TWO different commands. But it generally get the right one since when you [find]… The reason is kinda dorky… the cause a new subprocess, but it take the “path” of the part of the “parent command” as the context of what’s inside. So with something like /ip/address/set [find] comment=“same-comment-on-all” - the find takes it path from the outer “/ip/address”, so the find refers to the “match attributes version” of find. So to do the “string search version”, you’d need the [:find] (or, even [/find]) form since that ONLY exists at the / “root” of the command tree. Basically there is always some cwd (current working directory) in the shell, which allow the “right” find to be used.
On the dorky side, you can see two different find’s with /console/inspect:
[admin@dude] > /console/inspect request=syntax path=find
Columns: TYPE, SYMBOL, SYMBOL-TYPE, NESTED, NONORM, TEXT
TYPE SYMBOL SYMBOL-TYPE NESTED NONORM TEXT
syntax collection 0 yes
syntax <in> explanation 1 no array or string value to search
syntax <key> explanation 1 no value of key to find
syntax <from> explanation 1 no List of item numbers
[admin@dude] > /console/inspect request=syntax path=ip,address,find
Columns: TYPE, SYMBOL, SYMBOL-TYPE, NESTED, NONORM
TYPE SYMBOL SYMBOL-TYPE NESTED NONORM
syntax collection 0 yes
syntax <where> explanation 1 no