mirror of
https://github.com/ellysh/bash-programming-from-scratch.git
synced 2026-01-26 07:43:42 +00:00
15 lines
186 B
Bash
15 lines
186 B
Bash
#!/bin/bash
|
|
|
|
array=(1 25 -5 4 -9 3)
|
|
sum=0
|
|
|
|
for element in "${array[@]}"
|
|
do
|
|
if (( 0 < element ))
|
|
then
|
|
((sum += element))
|
|
fi
|
|
done
|
|
|
|
echo "The sum of the positive numbers is $sum"
|