Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How could I sum numbers? Expert help me PLS!!

Status
Not open for further replies.

kiros

Technical User
Jan 10, 2003
4
0
0
JP
This is the column of Inputs

2434
7870
843
9087

How could I sum them by unix command?
Do I have to use loop?
 
Hi:

Three other ways:

#!/bin/ksh
# integer arthmetic

# ksh
x=$((2434 + 7870 + 843 + 9087))
echo $x

# sh
x=`expr 2434 + 7870 + 843 + 9087`
echo $x

# bc
x=$(bc << EDS
scale=1
2434 + 7870 + 843 + 9087
EDS)
echo $x

Regards,

Ed
 
Answer's Tdatgod is that I need. Thank you so much.
Anyway, Olded. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top