Marius Marius - 1 year ago 74
Bash Question

Can't fill bash array

I'm running Ubuntu 14.04 and am trying to fill an array in a shell script so that I can loop over it and utilize its contents to fill a text file. However, there's a snag: it doesn't seem to be filling.

I've simplified the larger script that I'm working with down to the essential issue, reprinted below:

wl_range=$(seq $WL_START $WL_INC $WL_END)

declare -a WL

for i in $wl_range # loop through sequence and fill array

echo $wl_range
echo ${wl_range[1]}
echo $WL
echo ${WL[1]}

However, my output looks like this:

1 2 3 4 5

empty line

empty line

empty line

Any ideas? I know that people say to just use seq to fill the array, but I had the same problem there as well.

Answer Source

Too much work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download