Filter a command output

From MikroTik Wiki
Jump to navigation Jump to search

The following command if pasted into the terminal will print all ppp active users having names starting from "ex":

:global list ""; :foreach i in [/ppp active find] do={:if ([:find [/ppp active get $i name] "ex"]=0) 
  do={:set list ($list . "," . $i);}}; /ppp active print detail without-paging from $list; 


[admin@] > 
Flags: R - radius 
 0   name="ex" service=l2tp caller-id="" address= 
     uptime=3w3h34m48s encoding="" session-id=0x81E00000 limit-bytes-in=0 

 1   name="ex2" service=l2tp caller-id="" address= 
     uptime=17m14s encoding="" session-id=0x81E00001 limit-bytes-in=0 

[admin@] >