Perhaps you mean this?
val1=$1 val2=$2 for i in {1..10}; do array[i]=$(( val1 + val2 )) (( ++val1 )) done echo "${array[@]}"
If you bash do not support {x..y}
, use this format:
for (( i = 1; i <= 10; ++i )); do
Also simpler form
array[i]=$(( val1 + val2 )) (( ++val1 ))
Is an
(( array[i] = val1 + val2, ++val1 ))
source share