[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash scripting question



I am trying to solve a bash scripting problem, but I cannot figure it
out.

I frequently need to execute a command of the form:
	for x 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
		<do something with each x> ;
	done

This works fine if I actually type out the entire alphabet list on the
command line as above, but that's sort of a pain. So, I tried setting a
shell variable to the alphabet string (export alpha="A,B,C,...,Z"), but
then the command:
	for x in {$alpha} ; 
	do
		echo $x;
	done
winds up printing the string "{A,B,C,...,Z}" rather than each letter on
a separate line as expected.

I've tried various versions, including escaping the {} characters, etc,
using xargs, etc, but I cannot hit upon a sequence that works.

I also tried writing a program that printed the alphabet string to
stdout, but same results.

Can anyone suggest a syntax that would do the trick here?

Thanks.
nl





Reply to: