Sponsored Content
Top Forums Shell Programming and Scripting how to get the sum of all the lines in the file Post 302217340 by sdosanjh on Tuesday 22nd of July 2008 01:54:22 PM
Old 07-22-2008
dear all...thanx for your quick responses..... it helped me a lot to solve the issue....
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sum of all lines in file without roundup with awk

Hi, I have a file and I want to sum all the numbers in it. Example of the file: 0.6714359 -3842.59553830551 I used your forum (https://www.unix.com/shell-programming-scripting/74293-how-get-sum-all-lines-file.html) and found a script, what worked for me: awk '{a+=$0}END{print a}'... (8 Replies)
Discussion started by: mario8eren
8 Replies

2. Shell Programming and Scripting

Sum value from selected lines script (awk,perl)

Hello. I face this (2 side) problem. Some lines with this structure. ........... 12345678 4 12345989 13 12346356 205 12346644 74 12346819 22 ......... The first field (timestamp) is growing (or at least equal). 1)Sum the second fields if the first_field/500 are... (8 Replies)
Discussion started by: paolfili
8 Replies

3. Shell Programming and Scripting

sum of a column and selecting lines with value above threshold

Hi again, I need to further process the results of a previous manipulation. I have a file with three columns e.g. AAA5 0.00175 1.97996e-06 AAA5 0.01334 2.14159e-05 AAA5 0.01340 4.12155e-05 AAA5 0.01496 1.10312e-05 AAA5 0.51401 0.0175308 BB0 0.00204 2.8825e-07 BB0 0.01569 7.94746e-07 BB0... (6 Replies)
Discussion started by: f_o_555
6 Replies

4. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

5. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum

Hi friends, This is sed & awk type question. It is slightly different from my previous question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers (but no more than 10 numbers in series) whenever i find it and produce an output file with the... (4 Replies)
Discussion started by: kaaliakahn
4 Replies

6. Shell Programming and Scripting

Sum from successive lines following date header to create data for graphing connections

Hi, I have a log file created from a load balancer showing connections to each member of a two member pool with the following format (where first field is source IP, second field is load balanced IP address and third field is destination member. I need to plot a graph by date/time and number of... (5 Replies)
Discussion started by: shog63
5 Replies

7. UNIX for Dummies Questions & Answers

awk to sum column field from duplicate row/lines

Hello, I am new to Linux environment , I working on Linux script which should send auto email based on the specific condition from log file. Below is the sample log file Name m/c usage abc xxx 10 abc xxx 20 abc xxx 5 xyz ... (6 Replies)
Discussion started by: asjaiswal
6 Replies

8. Shell Programming and Scripting

Sum product of even/odd lines

Hi, I have a text file like this 6.0000E-02 0.00000E+00 0.0000 0.00000E+00 0.0000 7.0000E-02 5.00000E-10 1.0000 5.00000E-10 1.0000 8.0000E-02 3.00000E-09 0.4082 3.00000E-09 0.4082 9.0000E-02 3.50000E-09 0.3780 3.50000E-09 0.3780 1.0000E-01 1.00000E-09... (2 Replies)
Discussion started by: f_o_555
2 Replies

9. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies

10. Shell Programming and Scripting

awk to update file with sum of matching fields in another file

In the awk below I am trying to add a penalty to a score to each matching $1 in file2 based on the sum of $3+$4 (variable TL) from file1. Then the $4 value in file1 is divided by TL and multiplied by 100 (this valvue is variable S). Finally, $2 in file2 - S gives the updated $2 result in file2.... (2 Replies)
Discussion started by: cmccabe
2 Replies
sum(1)							      General Commands Manual							    sum(1)

NAME
sum - Displays the checksum and byte count in block-size (1024) units of a file SYNOPSIS
sum [-o | -r] [file...] The sum command reads file and calculates a 16-bit checksum and the byte count in block-size (1024) units in the file. If the file argu- ment is omitted, sum reads standard input. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: sum: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] Uses an algorithm to compute the checksum using word-by-word computation. Uses an alternate algorithm to compute the check- sum (rigorous byte-by-byte computation rather than the word-by-word computation). [Tru64 UNIX] This is the default. OPERANDS
The file for which a checksum is to be computed. If this operand is omitted, standard input is used. DESCRIPTION
The checksum and number of blocks are written to standard output. The sum command is generally used to determine if a file that was copied or communicated over transmission lines is an exact copy of the original. The sum command writes the space used in 1024-byte units. [Tru64 UNIX] The checksum is calculated using a rigorous byte-byte computation by default. System V Compatibility [Tru64 UNIX] The checksum algorithms for the default sum command and the SVID 2 compliant sum command are reversed. The SVID 2 compliant sum command uses the word-by-word algorithm by default and uses the byte-by-byte algorithm if you specify the -r option on the command line. NOTES
The sum utility is marked LEGACY in XCU Issue 5. [Tru64 UNIX] The default algorithm is no longer the word-by-word computation algorithm. It was changed to the 4.3BSD default algorithm. The algorithms used may not be portable, that is, the same checksum may not be produced for the same input on different systems. Portable applications should use cksum. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To display the checksum of datafile and the number of blocks in this file, enter: sum datafile If the checksum of datafile is 1605 and if the file contains 3 blocks, sum displays: 1605 3 datafile ENVIRONMENT VARIABLES
The following environment variables affect the execution of sum: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: cksum(1), wc(1) Standards: standards(5) sum(1)
All times are GMT -4. The time now is 11:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy