sum of array elements bash
read -a array
tot=0
for i in ${array[@]}; do
let tot+=$i
done
echo "Total: $tot"
Are there any code examples left?
New code examples in category Shell/Bash
read -a array
tot=0
for i in ${array[@]}; do
let tot+=$i
done
echo "Total: $tot"