I am trying to create a script where the sum of the array is what prints but my results just end up showing me "Sum: 0"
Here is my script so far.
Any help in correcting this would be appreciated.
#! /bin/bash
declare -a array1={1 2 3 4}
#read array
read -a array1
#set sum to zero
sum=0
#loop for sum in array
for i in ${array1[@]}; do
let sum+=$i
done
#print
echo "Sum: $sum"