mirror of
https://github.com/ellysh/bash-programming-from-scratch.git
synced 2026-01-26 07:43:42 +00:00
17 lines
222 B
Bash
17 lines
222 B
Bash
#!/bin/bash
|
|
|
|
array=(1 25 -5 4 -9 3)
|
|
sum=0
|
|
|
|
for element in "${array[@]}"
|
|
do
|
|
if (( element < 0))
|
|
then
|
|
continue
|
|
fi
|
|
|
|
((sum += element))
|
|
done
|
|
|
|
echo "Сумма положительных чисел равна $sum"
|