Apr 4, 2003 #1 kiros Technical User Jan 10, 2003 4 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?
This is the column of Inputs 2434 7870 843 9087 How could I sum them by unix command? Do I have to use loop?
Apr 5, 2003 #2 tdatgod Programmer Jul 21, 2001 601 US awk '{ tot += $1 } END { print tot }' <file> Upvote 0 Downvote
Apr 5, 2003 #3 olded Programmer Oct 27, 1998 1,065 US 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 Upvote 0 Downvote
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
Apr 5, 2003 Thread starter #4 kiros Technical User Jan 10, 2003 4 JP Answer's Tdatgod is that I need. Thank you so much. Anyway, Olded. Thanks for your help. Upvote 0 Downvote