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

Re: bash scripting question



shaulka@bezeqint.net <shaulka@bezeqint.net> [2002-11-03 18:15:06 +0200]:
> On Sat, Nov 02, 2002 at 10:05:45PM -0600, Michael Heironimus wrote:
> > alpha="a b c d e .... z"
> > for x in $alpha ; do
> >         echo $x
> > done
> > 
> > I think this should work in any Bourne-style shell....
> 
> Doesn't work for me in bash:
> 
> $ for x in "a b c d e .... z"; do printf "$x "; done; printf "\n"
> a b c d e .... z 
> $

I believe they were using ... as a euphemism to say fill in the entire
sequence literally.

> As for the original poster, an ugly solution might be with seq and tr:
> 
> $ for x in $(seq 1 5); do export y=$(printf "$x" | tr 1-5 a-e); printf
> "$y "; done; printf "\n" 
> a b c d e 

Very cute!  I like it.

Bob

Attachment: pgpaFkDZg7WTD.pgp
Description: PGP signature


Reply to: