Looping through alphabets in Bash

here's how to generate the Spanish alphabet using nested brace expansion

for l in {{a..n},ñ,{o..z}}; do echo $l ; done | nl
1  a
 ...
14  n
15  ñ
16  o
...
27  z

Or simply

echo -e {{a..n},ñ,{o..z}}"\n" | nl

If you want to generate the obsolete 29 characters Spanish alphabet

echo -e {{a..c},ch,{d..l},ll,{m,n},ñ,{o..z}}"\n" | nl

Similar could be done for French alphabet or German alphabet.


Using rename:

mkdir -p path2/{a..z}
rename 's|path1/([a-z])(.*)|path2/$1/$1$2' path1/{a..z}*

If you want to strip-off the leading [a-z] character from filename, the updated perlexpr would be:

rename 's|path1/([a-z])(.*)|path2/$1/$2' path1/{a..z}*

for x in {a..z}
do
    echo "$x"
    mkdir -p path2/${x}
    mv path1/${x}*.ext path2/${x}
done

This should get you started:

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