![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to perfrom summation for particular delimited field? | rauphelhunter | Shell Programming and Scripting | 2 | 10-19-2007 01:29 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Using awk or bc for summation...
Hello, Here is what I want to do: I have two files composed of a single column of values (same number of line in both files) having a scientific format (eg. 2.038189E-04). I would like to sum these two files to get a single column of values (the first value would be equal to the sum of the values of the first lines, the second value equal to the sum of the second lines,...). Is that possible to use awk to do this summation in a minimum of operation or is it necessary to do a for loop to sum the lines one by one? I already did some search on this forum and find the following code to use awk to sum values: Code:
awk -v a="1.234567e-05" -v b="9.876e-04" 'BEGIN{print (a + b)}'
How should I modify that? Also how can I force the number of digits after the point (I want my output format to be x.xxxxxxE-xx). Thanks for you help... |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|