Adding Long List Of Large Numbers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding Long List Of Large Numbers
# 1  
Old 07-18-2013
Adding Long List Of Large Numbers

Hi All,

I have a file with long list of numbers. This file contains only one column. These numbers are very large. I am using following command:

Code:
cat myfile.txt | awk '{ sum+=$1} END {print sum}'

The output is coming in scientific notation. How do I get the result in proper format?

Thanks
Angshuman
# 2  
Old 07-18-2013
can u show the contents of the input file.
# 3  
Old 07-18-2013
... whatever is the "proper format"...
For a non-scientific notation use printf and the %f conversion specifier, or set the OFMT variable accordingly.
# 4  
Old 07-18-2013
Hi,

I have attached the file. For this file, when I run the command, I get the result as

Code:
cat myfile.txt | awk '{ sum+=$1} END {print sum}'
5.69169e+06

# 5  
Old 07-18-2013
As said, use printf not print.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse for 2 numbers in large single line

Hi All, I am writing a script in which I need to gather 2 numbers for 'total' and 'successful'. The goal is to compare the two numbers and if they are not equal, rerun the task until all are successful. I'm thinking the best way will be with awk or sed, but I really don't know where to begin... (8 Replies)
Discussion started by: hburnswell
8 Replies

2. Shell Programming and Scripting

Adding lines to a large file

Hello, I have a relatively large text file (25,000K) consisting of records of data. For each record, I need to create a new line based on what is already there. Every record has a block that looks like, M END > <ID> 1 > <SOURCE> KEGG > <SOURCE_ID> C00002 > <NAME> ATP;... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

3. Shell Programming and Scripting

Adding (as in arithmetic) to numbers in columns in file, and writing new file with new numbers

Hi again. Sorry for all the questions — I've tried to do all this myself but I'm just not good enough yet, and the help I've received so far from bartus11 has been absolutely invaluable. Hopefully this will be the last bit of file manipulation I need to do. I have a file which is formatted as... (4 Replies)
Discussion started by: crunchgargoyle
4 Replies

4. UNIX for Dummies Questions & Answers

Find common numbers from two very large files using awk or the like

I've got two files that each contain a 16-digit number in positions 1-16. The first file has 63,120 entries all sorted numerically. The second file has 142,479 entries, also sorted numerically. I want to read through each file and output the entries that appear in both. So far I've had no... (13 Replies)
Discussion started by: Scottie1954
13 Replies

5. UNIX for Dummies Questions & Answers

Hope to create a file with two large column, with several numbers

I hope to create a file made up of 2 columns - first column print out number 0~61000 every 50 of it - second column just contains 0 delineated by space such as 0 0 50 0 100 0 150 0 200 0 ... 60900 0 60950 0 61000 0 Which command should I need to use? I think I might need to use... (5 Replies)
Discussion started by: exsonic
5 Replies

6. Programming

Working with extremely large numbers in C

Hi All, I am just curious, not programming anything of my own. I know there are libraries like gmp which does all such things. But I really need to know HOW they do all such things i.e. working with extremely large unimaginable numbers which are beyond the integer limit. They can do add,... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Shell Programming and Scripting

adding a list of numbers 3 by 3

i have a list of numbers like this; 124 235 764 782 765 451 983 909 ... and i want to make a sum with the first 3 of them then the next 3 and so on. 124+235+764=1123 782+765+451=1998 ... some ideas? (4 Replies)
Discussion started by: Tártaro
4 Replies

8. UNIX for Dummies Questions & Answers

Grep alternative to handle large numbers of files

I am looking for a file with 'MCR0000000716214' in it. I tried the following command: grep MCR0000000716214 * The problem is that the folder I am searching in has over 87000 files and I am getting the following: bash: /bin/grep: Arg list too long Is there any command I can use that can... (6 Replies)
Discussion started by: runnerpaul
6 Replies

9. UNIX for Dummies Questions & Answers

adding long user name

hello everybody: I need to add a 10 character user name to my tru64 system, is there any work around I can use for that. thanks alot (1 Reply)
Discussion started by: aladdin
1 Replies

10. Shell Programming and Scripting

How to parse large numbers of shell scripts

I am trying to parse hundreds of shell scripts to determine how they related to each other. Ideally for every script, I would get an output of: What other scripts it calls What files it reads Environment variables it accesses Any ideas on how to do this? TIA! (2 Replies)
Discussion started by: bliss
2 Replies
Login or Register to Ask a Question