Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of my system have bash version 2.05.8, which is quite older. Now on this machine ii tried to use for loop in following format

 for i in {a..z}

But this gives , Please suggest the right statement

share|improve this question
I'm not sure if you're using a and z as stand-ins for numbers, in which case the answer using seq should suffice, or if your intention is to generate the alphabet; could you please elaborate? – Eduardo Ivanec Apr 13 '11 at 14:26
Yes i want to generate a-z alphabets , not numbers – vnix27 Apr 13 '11 at 14:41

I'm not aware of a version of seq that works with letters. Do you have perl available? In that case:

for i in `perl -e "$,=' '; print a..z"`; do echo $i; done

I got the $,=' ' obscure part here:

Of course I'm assuming you need to generate dynamic slices of the alphabet, otherwise this is probably not worth the effort and you should stick to:

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 echo $i; done
share|improve this answer
Thanks for, for i in perl -e "$,=' '; print a..z"; do echo $i; done – vnix27 Apr 13 '11 at 15:53

Ranges only work for bash 3.0+

Your syntax is correct however:

for i in {1..5}
    echo "$i) Bash version ${BASH_VERSION}"
share|improve this answer
for i in {1..5}; do echp $i; done – 3molo Apr 13 '11 at 13:40
It doesn't works in my case due to older bash version – vnix27 Apr 13 '11 at 14:42

Try this instead: for i in $(seq 1 5)

share|improve this answer

Your Answer


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.