The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-15-2006
burakkilic burakkilic is offline
Registered User
 

Join Date: May 2006
Posts: 6
Problems with sum operation

i wrote this code..

#!/bin/sh
sum=0
for i in `cat numbers.txt |cut -f1`
do
sum=expr $sum + $i
done
echo $sum


I want to read the numbers in the file numbers.txt. and find sum of them. But this code only writes the numbers(without making sum) that it reads. Help me..
Reply With Quote
Forum Sponsor