> On Sat, Oct 05, 2019 at 06:48:35PM +0000, George R Goffe via Bug reports for 
> the GNU Bourne Again SHell wrote:
>> I was expecting to see:
>> 12345
> 
> If you want to create a *list* and iterate over that list, one element
> at a time, use arrays instead of string variables.
> 
> x=(1 2 3 4 5)
> for z in "${x[@]}"; do
>   echo "$z"
> done

Just to be clear (as nobody has mentioned this) to get them all on the
same line, you need "echo -n", and you can do this without using arrays:

x="1 2 3 4 5"
for z in $x
do echo -n "$z"
done

Cheers,
Peter




Reply via email to