If you want to process process numbers one by one, taking advantage of shell word splitting :
numbers="3829 4837 3729 2874 3827"
for n in $numbers; do
# do something with "$n"
done
SUM
:
numbers="3829 4837 3729 2874 3827"
echo $((${numbers// /+}))
or
numbers="3829 4837 3729 2874 3827"
for n in $numbers; do
((sum+=n))
done
echo $sum
LARGEST
:
numbers="3829 4837 3729 2874 3827"
for n in $numbers; do
((max<n)) && max=$n
done
echo $max
Alternatively, if you want a global SUM
with some shell tricks :
$ tr ' ' '+' <<< '3829 4837 3729 2874 3827' | bc
19096
or
$ awk '{$1=$1; print}' OFS=+ <<< '3829 4837 3729 2874 3827' | bc
19096
or
$ echo '3829 4837 3729 2874 3827' |
awk '{for (i=1; i<=NF; i++) c+=$i} {print c}'
19096