vehomzzz vehomzzz - 2 months ago 11
Bash Question

How can I make the list of letters from A to Z and iterate through them in the shell?

Say I want to iterate from letter A to letter Z in csh shell. How do I succinctly do that?

In bash I would do something like

for i in 'A B C ...Z'; do echo $i; done


The point is I don't want to write A through Z, I want something like

[A-Z]


Can you suggest a one line suggestion in AWK or Perl?

mob mob
Answer

Perl

$,=" ";print +(A..Z)

or to use inside a shell:

for i in `perl -e '$,=" ";print +(A..Z)'` ; do echo $i ; done