[ale] sequencing the alphabet

Alex LeDonne aledonne.listmail at gmail.com
Tue May 8 15:45:48 EDT 2007


On 5/8/07, Jim Popovitch <yahoo at jimpop.com> wrote:
> Every now and then I need to do a for loop and iterate through the
> alphabet.  If I was iterating through numbers I could use seq to output
> a sequence like this:
>
> for i in `seq 0 9`; do ....
>
> What I need to do is something like this:
>
> for i in `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`; do .....
>
> Any idea on how to keep from typing 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 every time?
>
> Tia,
>
> -Jim P.

In bash:

for i in {a..z};
 do echo $i;
done

Note that this does the right thing for numbers... {0..20} does what
you would expect. See "Brace expansion" in your bash manpage.

I don't see anything similar in sh. What's the environment requirement?

-A



More information about the Ale mailing list