1 |
On Sun, Mar 05, 2006 at 09:50:36PM +0100, Penguin Lover Alexander Skwar squawked: |
2 |
> Franta wrote: |
3 |
> |
4 |
> > oracle@frankies ~/MyDB $ for AA in [0-9][0-9] ; do echo $AA; done |
5 |
> > [0-9][0-9] |
6 |
> > oracle@frankies ~/MyDB $ |
7 |
> > |
8 |
> > Is this fixed somehow? |
9 |
> |
10 |
> [0-9][0-9] will do file name globbing, it seems. Do: |
11 |
> |
12 |
> touch 00 99 |
13 |
> |
14 |
|
15 |
It works for globbing as wild cards, but won't work for what he wants |
16 |
(I think.) |
17 |
|
18 |
If you want to expand everything from 00 to 99, you want brace |
19 |
expansion: |
20 |
|
21 |
[05:41 PM]wwong ~ $ echo {0..9}{0..9} |
22 |
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
23 |
[05:42 PM]wwong ~ $ echo {0..99} |
24 |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
25 |
|
26 |
It also works for letters |
27 |
|
28 |
[05:45 PM]wwong ~ $ echo {A..z} |
29 |
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ a b c d e f g h i j k l m n o p q r s t u v w x y z |
30 |
|
31 |
So, what you wanted would be |
32 |
for AA in {0..9}{0..9}; do echo $AA; done |
33 |
|
34 |
What you had (for AA in [0-9][0-9]) would be interpreted by bash as: |
35 |
for AA in {filename that matches the glob [0-9][0-9]} |
36 |
which, if you don't have any files named like that, will be |
37 |
for AA in {null string} |
38 |
and hence the behaviour you saw. |
39 |
|
40 |
W |
41 |
-- |
42 |
I am a nobody |
43 |
Nobody is perfect |
44 |
Therefore, I am perfect. |
45 |
Sortir en Pantoufles: up 113 days, 15:06 |
46 |
-- |
47 |
gentoo-user@g.o mailing list |