dima@fatty:/media/usb/DCIM/100RICOH$ ls R<22399-22402>*
R0022399.JPG R0022400.JPG R0022401.JPG R0022402.JPG
dima@fatty:/media/usb/DCIM/100RICOH$ bash -c 'ls R {22392..22402}*'
ls: cannot access R22399*: No such file or directory
ls: cannot access R22400*: No such file or directory
ls: cannot access R22401*: No such file or directory
ls: cannot access R22402*: No such file or directory
Bash seems to treat these as strings, not like numbers. So in this specific case, I could have manually counted the number of 0s that are required. In some other case where the field width wasn't constant, I wouldn't be able to do that. What if I have files
How do I pick 9-11 in bash? The point is zsh has features that are a real productivity boost. It's certainly arguable whether a switch is worthwhile, but claiming that these features are just "cosmetic" is wrong.
Your point is correct -- Bash is treating these as strings. I didn't have your file names so I tried a similar example, and I just realized I have to correct my example. I have a directory of graphic files with embedded numbers with leading zeros, for example 001 to 031. I was able to say:
$ ls geographic_harbor_2012_06_02_*{1..31}.JPG
And get all the members. But it's not the same as your example.
Comments
Ugh... Did you actually try this?
Bash seems to treat these as strings, not like numbers. So in this specific case, I could have manually counted the number of 0s that are required. In some other case where the field width wasn't constant, I wouldn't be able to do that. What if I have filesfile.1, file.2, file.3, ..., file.9, file.10, file.11, ...
How do I pick 9-11 in bash? The point is zsh has features that are a real productivity boost. It's certainly arguable whether a switch is worthwhile, but claiming that these features are just "cosmetic" is wrong.
> Neither would match all files.
True, but this works: file.*{9..11}
It globs on the LHS, and requires the RHS to be literally consistent with the generated index.
I had the same problem with my earlier example, and the above is how I worked it out.
> Ugh... Did you actually try this?
Your point is correct -- Bash is treating these as strings. I didn't have your file names so I tried a similar example, and I just realized I have to correct my example. I have a directory of graphic files with embedded numbers with leading zeros, for example 001 to 031. I was able to say:
$ ls geographic_harbor_2012_06_02_*{1..31}.JPG
And get all the members. But it's not the same as your example.
How old is your Bash? GNU bash, version 4.2.37(2)-release produces
Read the post again. Your case works because you have exactly the right number of digits.
Missed that. Well, Bash does it intuitively however you like: