chiark / gitweb /
New script to add up numbers on stdin.
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Wed, 9 Mar 2005 13:24:02 +0000 (13:24 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Wed, 9 Mar 2005 13:24:02 +0000 (13:24 +0000)
total [new file with mode: 0755]

diff --git a/total b/total
new file mode 100755 (executable)
index 0000000..fe1c143
--- /dev/null
+++ b/total
@@ -0,0 +1,7 @@
+#! /bin/sh -e
+
+total=0
+for num in $(cat); do
+       total="$(($total + $num))"
+done
+echo "$total"