Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
What version of bash are you working with? Works for me with $BASH_VERSION = 4.1.10(4)-release –  glenn jackman Jul 14 '11 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. –  iconoclast Jul 14 '11 at 19:34
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
Was that bug fixed by Lumberg, by any chance? –  l0b0 Jul 15 '11 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? –  Gilles Jul 15 '11 at 9:38
    
Pop culture reference. Don't worry about it. –  l0b0 Jul 15 '11 at 13:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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