System information

Manual:API
162
Queries
print command accepts query words that limit set of returned sentences. This feature is available since RouterOS
3.21.
Query words begin with '?'.
Order of query words is significant. Query is evaluated starting from the first word.
Query is evaluated for each item in the list. If query succeeds, item is processed, if query fails, item is ignored.
Query is evaluated using a stack of boolean values. Initially stack contains infinite amount of 'true' values. At the
end of evaluation, if stack contains at least one 'false' value, query fails.
Query words operate according to the following rules:
Query Desciption
?name pushes 'true' if item has value of property name,
'false' if it does not.
?-name pushes 'true' if item does not have value of property
name, 'false' otherwise.
?name=x
?=name=x
pushes 'true' if property name has value equal to x,
'false' otherwise.
?<name=''x''''' |style="border-bottom:1px solid gray;" valign="top"| pushes 'true' if
property ''name'' has value less than ''x'', 'false' otherwise. |-
|style="border-bottom:1px solid gray;" valign="top"|'''?>name=x
pushes 'true' if property name has value greater than
x, 'false' otherwise.
?#operations applies operations to the values in the stack.
operation string is evaluated left to right.
sequence of decimal digits followed by any
other character or end of word is interpreted as a
stack index. top value has index 0.
index that is followed by a character pushes
copy of value at that index.
index that is followed by the end of word
replaces all values with the value at that index.
! character replaces top value with the opposite.
& pops two values and pushes result of logical
'and' operation.
| pops two values and pushes result of logical
'or' operation.
. after an index does nothing.
. after another character pushes copy of top
value.
Examples:
Get all ethernet and VLAN interfaces:
/interface/print
?type=ether
?type=vlan
?#|
Get all routes that have non-empty comment:
/ip/route/print
?>comment=
Forum thread with detailed explanation of use of queries
[1]