On Sun, 2006-03-05 at 17:48 -0500, Willie Wong wrote:
> On Sun, Mar 05, 2006 at 09:50:36PM +0100, Penguin Lover Alexander Skwar 
> squawked:
> > Franta wrote:
> > 
> > > [EMAIL PROTECTED] ~/MyDB $ for AA in [0-9][0-9] ; do echo $AA; done
> > > [0-9][0-9]
> > > [EMAIL PROTECTED] ~/MyDB $
> > > 
> > > Is this fixed somehow?
> > 
> > [0-9][0-9] will do file name globbing, it seems. Do:
> > 
> > touch 00 99
> > 
> 
> It works for globbing as wild cards, but won't work for what he wants
> (I think.)
> 
> If you want to expand everything from 00 to 99, you want brace
> expansion:
> 
> [05:41 PM]wwong ~ $ echo {0..9}{0..9}
> 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
> [05:42 PM]wwong ~ $ echo {0..99}     
> 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
> 
> It also works for letters
> 
> [05:45 PM]wwong ~ $ echo {A..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 [  ] ^ _ 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
> 
> So, what you wanted would be
>  for AA in {0..9}{0..9}; do echo $AA; done
> 
> What you had (for AA in [0-9][0-9]) would be interpreted by bash as:
>   for AA in {filename that matches the glob [0-9][0-9]}
> which, if you don't have any files named like that, will be
>   for AA in {null string}
> and hence the behaviour you saw. 
> 
> W
> -- 
> I am a nobody
> Nobody is perfect
> Therefore, I am perfect.
> Sortir en Pantoufles: up 113 days, 15:06

Thanks,

seems I've worked under Wondies too long ;)

Frank


-- 
[email protected] mailing list

Reply via email to