2

In zsh, I get the expected result from both of these brace expansions:

$ touch file-{001..100} $ touch file-{1..100} 

The first one gives me files named file-001, file-002, etc., all the way to file-100. The second one gives me files named file-1, file-2, etc., all the way to file-100.

In bash, however, both give me files named file-1, file-2, etc. This strikes me as a pretty major bug (or design flaw) in bash's brace expansion.

Is there any way to configure bash to do the right thing in this case?

2
  • What version of bash are you working with? Works for me with $BASH_VERSION = 4.1.10(4)-release Commented Jul 14, 2011 at 19:22
  • The server I tested this on uses returns himBH 3.00.16(1)-release from echo $- $BASH_VERSION. Locally I get himvBH 3.2.17(1)-release. Both expand to 1-100 instead of 001-100. Commented Jul 14, 2011 at 19:34

1 Answer 1

5

This is a bug in older versions of bash, fixed in bash 4.1 alpha. From the changelog:

mm. Fixed a bug that in brace expansion that caused zero-prefixed terms to not contain the correct number of digits.

3
  • Was that bug fixed by Lumberg, by any chance? Commented Jul 15, 2011 at 8:10
  • @l0b0 I don't know; is the bash repository even public? And who's Lumberg and why would it matter who fixed the bug anyway? Commented Jul 15, 2011 at 9:38
  • Pop culture reference. Don't worry about it. Commented Jul 15, 2011 at 13:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.