Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (wolfe8):

Need help with awk commands. How to increase precision.

OpenStudy (wolfe8):

I have a file with 8 columns. I need to total up every row in columns 4 and 7. An example of a line in my file is: http://prntscr.com/3la298 When I awk it, I get http://prntscr.com/3la311 As you can see it doesn't read the values properly and stops at a few figures. How do I make it read everything in the column? Here is my awk file http://prntscr.com/3la4hg

OpenStudy (rsmith6559):

END { printf( "%.8f, %.8f, %.8f\n", totalx, totalpsi, h ) }

OpenStudy (wolfe8):

Thanks! I'll try that tomorrow when I go back to work.

OpenStudy (wolfe8):

One question, would that just print it with lots of decimal places? Because when I run it for the whole data file it just adds the 'shortened' values.

OpenStudy (wolfe8):

Sadly that did not work. I did figure out the source of the problem though. Awk can only read exponents in the form of e and not D. I changed that in my data file and awk runs fine now. Thanks for trying.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!