简体   繁体   中英

How to use variables in brace expansion

This works as expected:

$ echo file-{00..03}
file-00 file-01 file-02 file-03

This does not do what I wanted:

$ start=00
$ end=03
$ echo file-{$start..$end}
file-{00..03}

The reason is that brace expansion is performed before any other epansion.

In my case, the sequence limits are in the variables start and end .

Any clever way to hack my way around this?

I have this:

$ eval echo file-{$start..$end}
file-00 file-01 file-02 file-03

But I am open to less ugly suggestions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM