Apr 4, 2003 #1 kiros Technical User Joined Jan 10, 2003 Messages 4 Location 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 Joined Jul 21, 2001 Messages 601 Location US awk '{ tot += $1 } END { print tot }' <file> Upvote 0 Downvote
Apr 5, 2003 #3 olded Programmer Joined Oct 27, 1998 Messages 1,065 Location 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 Joined Jan 10, 2003 Messages 4 Location JP Answer's Tdatgod is that I need. Thank you so much. Anyway, Olded. Thanks for your help. Upvote 0 Downvote