The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-28-2007
tselvanin tselvanin is offline
Registered User
  
 

Join Date: Sep 2003
Posts: 10
shell script question

I am using ksh.

There is a report having amounts in the following format,

34343.67-
2343.45
23434.89-

I want to sum up all the amounts. For this I first need to find out if there is a minus sign at the end and prefix it before summing up. How to achieve this?

I thought of using an array to store the values and then sum up the amounts using a while loop. But don't have any clue as how to first convert the amounts to below format,

-34343.67
2343.45
-23434.89

Any help is appreciated.
Thanks!