ok now im working on another code. i have to add two arrays together to form one array.
all that i am getting for the output is 2. here is the code...i know i am missing a few things but i just do not know what exactly. i # some of my statements out to get some kind of result out. any advice is appreciated thanks
#!/bin/bash
a=(1 3 5 7 8)
b=(2 3 5 8 9 2)
c=( )
#size1=${#a[*]}
#size2=${#b[*]}
#echo "the size of 1: $size1"
#echo "the size of 2: $size2"
cnt=0
cnt1=0
cnt2=0
echo;
while [ $cnt -le ${#a[*]} -a $cnt -le ${#b[*]} ]
do
# echo ${a[cnt1]}${b[cnt2]}
c=$((${a[cnt1]}+${b[cnt2]}))
cnt=$((cnt+1))
cnt1=$((cnt1+1))
cnt2=$((cnt2+1))
done
echo "now the array is: ${c[*]}"
echo;
exit