8

I'm currently using combination of curly brackets and globing to play multiple files in vlc at once:

vlc K20-{06,07,08,09,10,11,12,13,14,15,16,17}*

But the numbers are alway full sequence, is there a way to somehow specify it a bit simplier, maybe something like

vlc K20-{06-17}*

? Maybe use seq somehow?

I can use

   $ echo K20-{$(seq -s, -f "%02.0f" 06 17)}*
K20-{06,07,08,09,10,11,12,13,14,15,16,17}*

but that does not seem to expand the *. Any way around it?

  • 7
    The syntax for a brace expansion range is {m..n} - so K20-{06..17}* – steeldriver Jul 8 '18 at 20:55
13

As @steeldriver notes, K20-{06..17}* covers it.

Example, using an echo for test/validation:

$ echo vlc K20-{06,07,08,09,10,11,12,13,14,15,16,17}*
vlc K20-06* K20-07* K20-08* K20-09* K20-10* K20-11* K20-12* K20-13* K20-14* K20-15* K20-16* K20-17*
$ echo vlc K20-{06..17}*
vlc K20-06* K20-07* K20-08* K20-09* K20-10* K20-11* K20-12* K20-13* K20-14* K20-15* K20-16* K20-17*

The * will be expanded as well if there are files that match the name in the present working directory.

So vlc K20-{06..17}* will achieve what you want.

More information on bash expansion at GNU Bash Reference Manual - Brace Expansion. Or from man bash, read:

A sequence expression takes the form {x..y[..incr]}, where x and y are either integers or single characters, and incr, an optional increment, is an integer.

So:

$ echo K20-{06..10}
K20-06 K20-07 K20-08 K20-09 K20-10

$ echo K20-{06..10..2}
K20-06 K20-08 K20-10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.