for dir in equil[0123] could iterate over folders of equil0, equil1,equil2 and equil3. But if I have folders with name number more than 10, e.g. equil23, how to properly refer to them? How the separator is recognised in equil[0123]?
Asked
Active
Viewed 23 times
0
lanselibai
- 133
- 2
- 5
-
Running the `for` loop as you describe only outputs one string `equil[0123]`. Something like `for dir in equil{0..3}; do echo $dir; done` would use bash brace expansion and output four lines with `equil0`, `equil1`, `equil2`, `equil3`. For more than 10, set the number to higher than 10: `for dir in equil{0..100}; do echo $dir; done`. Please clarify your question if none of that helps. – GracefulRestart Nov 08 '19 at 22:04
-
You could also use `extglob` to iterate over directories matching `equil` followed by one or more digits with the pattern `equil+([[:digit:]])` – m0dular Nov 08 '19 at 22:55