#!/bin/zsh # calcsum -- takes integer input and calculates the sum # http://www.jpsdomain.org/linux/OnStream_DI-30-RedHat_Backup_mini-HOWTO.html # v1.0 21-Feb-2001 JP Vossen # v1.1 15-Nov-2001 JPV Changed to use zsh, as RedHat 7.1 has # PD KSH v5.2.14 99/07/13.2 that fails as sh, etc. below. # Copyright 2001 JP Vossen # This script is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # In no event shall the author be liable for any damages whatsoever # (including, without limitation, damages for loss of business profits, # business interruption, loss of business information, or any other # pecuniary loss) arising out of the use of or inability to use this script. # NOTE: MUST use zsh because sh, bash, bash2 can't add! # At 2147483648 they start counting BACKWARDS. TOT=0 while read N; do let TOT=${TOT}+${N} done echo "${TOT}"