Use of ranges in the CLI

For tasks that are too cumbersome on Winbox tome some dummy value as reference then write a “script” (not really) and feed it line by line via SSH.

It works as long as I have a blank slate to work with. This means I still need to use Winbox to wipe all entries and hopefully, and depending on what I’m working with, send the commands fast enough before a TCP timeout or something so I’m not locked out.

I’d like to, say; remove all address lists or firewall rules before adding a new set, for which I’ve tried issuing "

/ip/address/remove numbers=1-100

" but as soon as I add the "

-

" I’m indicated it won’t work. The correct way to do it’s is by command substitution, but I’m struggling immensely with the syntax since it’s ambiguous what I can and can’t put in there and things that are tab-completed aren’t even in the docs (https://help.mikrotik.com/docs/display/ROS/Scripting, https://wiki.mikrotik.com/wiki/Manual:Scripting_Tips_and_Tricks).

For instance, in:

/ipv6/address> add address=2001:db8:b9::1 interface=[find where interface z] no-dad=yes
ambiguous value of interface, more than one possible value matches input

The goal there was to add the same address on all interfaces with “z” in the name. All interface names in my test router begin “z”. Depending on where I tab-completed it would either complete or show available options, among these “from=”, “in=” and “key=”*, all of which seems better options than “where”, but they don’t work with “interface” nor with Bash-style expansions like _[u]z[/u]**ºº, **{z0001..z0070}_, which is where my limited knowledge took me.

Could you guide me a little here? I’m only looking to learn how to enter ranges, e.g; “numbers 3 through 30 from the list”, but I’ll be grateful for any extras you’d like to throw in there, then perhaps I can move away from wiping clean and use real scripts with heuristics to modify things. :slight_smile: Thanks!


ºº: what is key BTW? I assumed it was what’s next to a value, such as “interface” in > __

interface=z0094

>
> but given where it's offered by tab-completion, I'm not that confident anymore.