public
Description: personal scripts
Homepage:
Clone URL: git://github.com/mackstann/bin.git
bin / Sum
100755 18 lines (13 sloc) 0.293 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh
 
# Written by Nick Welch <nick@incise.org>. Author disclaims copyright.
 
# Sum: take white-space (including newline)-delimited numbers from stdin and
# echo the sum.
 
total=0
while read line
do
for num in $line
    do
total=$(($total + $num))
    done
done
echo $total