[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is this a bug by any chance?
From: |
pepa65 |
Subject: |
Re: Is this a bug by any chance? |
Date: |
Mon, 7 Oct 2019 20:05:12 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
> 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