03-21-2011
thanks bartus. I see awk '{tot=tot+$1} END {print tot}' file1 does same thing
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi
I want to sum of 3 columns in file.
Example: I want to sum of 3 ,6,8 th columns in file(SUM(3,6,8)).
Using awk can sum of single column
awk '{a+=$3} END {printf ("%f\n",a)' file_name
Thanks inadvance
MR (2 Replies)
Discussion started by: mohan705
2 Replies
2. Shell Programming and Scripting
Hello everyone I need to write a script that sums numbers passed to it as arguments on the command line and displays the results. I must use a for loop and then rewrite it using a while loop. It would have to output something like 10+20+30=60
this is what I have so far
fafountain@hfc:~$ vi sum... (1 Reply)
Discussion started by: Blinky85
1 Replies
3. Shell Programming and Scripting
Hi
i data looks like this:
student 1
Subject1 45 55
Subject2 44 55
Subject3 33 44
//
student 2
Subject1 45 55
Subject2 44 55
Subject3 33 44
i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies
4. UNIX for Dummies Questions & Answers
I am trying to get the sum of the first column of a file. When I use the same method for other files it works just fine... for some reason for the file below it gives me an error that I don't understand... I tried looking at different lines of the file and tried different things, but I still... (7 Replies)
Discussion started by: cosmologist
7 Replies
5. Shell Programming and Scripting
Hi, Unix Gurus,
I need sum values from a file. file format like:
0004004
0000817
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0045000
0004406
the result should be 459227 (817+45000 ... + 4406)
anybody can help me out (7 Replies)
Discussion started by: ken002
7 Replies
6. Shell Programming and Scripting
I have a list of values ( in Kb) I have the following code to sum up the values and convert the total to GB
cat list
701368101370
101370101370
801554101370
701636101370
101757101370
101876101370
901951101370
And this is the output of my script
awk '{ s += $1 } END {... (3 Replies)
Discussion started by: Sara_84
3 Replies
7. Shell Programming and Scripting
Hi Friends,
I have a file with fields separated with comma. How to print sum of each field of the file?
Eg:
input file
1,3,6,7
2,1,2,1
0,1,1,0
I want to sum each field separately.
Output file
3,5,9,8
Thanks,
Suresh (2 Replies)
Discussion started by: suresh3566
2 Replies
8. UNIX for Dummies Questions & Answers
Dear masters,
I have file input
011171646073|12129|12129|A027|20141001|20141015|2014|10|01|2013|10|15
011171646076|12129|12129|A027|20141001|20141012|2014|10|01|2014|09|12
011171646078|12129|12129|A027|20141001|20141015|2014|10|01|2014|10|15... (6 Replies)
Discussion started by: radius
6 Replies
9. Shell Programming and Scripting
hi Gurus,
I have an extract as seen below:
INPUT
2015-08-24 15:00:00.0 |TCSERVER01 |ServiceEventHandler |2283
2015-08-24 15:01:00.0 |TCSERVER01 |ServiceEventHandler |576
2015-08-24 15:02:00.0 |TCSERVER01 |ServiceEventHandler |833
2015-08-24 15:03:00.0 |TCSERVER01 |ServiceEventHandler... (6 Replies)
Discussion started by: reignangel2003
6 Replies
10. Shell Programming and Scripting
HI Guys,
I gave Input file F.Txt
ID H1 H2 H3 H4 H5
A 5 6 7 8 9
B 4 65 4 4 7
C 4 4 4 4 4
D 4 4 4 4 4
Output :-
ID H1 H2 H3 H4 H5
Total 17 79 19 20 24
Sum of Each Columns (8 Replies)
Discussion started by: pareshkp
8 Replies
sum(n) Cyclic Redundancy Checks sum(n)
__________________________________________________________________________________________________________________________________________________
NAME
sum - Calculate a sum(1) compatible checksum
SYNOPSIS
package require Tcl 8.2
package require sum ?1.1.0?
::crc::sum ?-bsd | -sysv? ?-format fmt? ?-chunksize size? [ -filename file | -channel chan | string ]
_________________________________________________________________
DESCRIPTION
This package provides a Tcl-only implementation of the sum(1) command which calculates a 16 bit checksum value from the input data. The
BSD sum algorithm is used by default but the SysV algorithm is also available.
COMMANDS
::crc::sum ?-bsd | -sysv? ?-format fmt? ?-chunksize size? [ -filename file | -channel chan | string ]
The command takes string data or a file name or a channel and returns a checksum value calculated using the sum(1) algorithm. The
result is formatted using the format(n) specifier provided or as an unsigned integer (%u) by default.
OPTIONS
-sysv The SysV algorithm is fairly naive. The byte values are summed and any overflow is discarded. The lowest 16 bits are returned as the
checksum. Input with the same content but different ordering will give the same result.
-bsd This algorithm is similar to the SysV version but includes a bit rotation step which provides a dependency on the order of the data
values.
-filename name
Return a checksum for the file contents instead of for parameter data.
-channel chan
Return a checksum for the contents of the specified channel. The channel must be open for reading and should be configured for
binary translation. The channel will no be closed on completion.
-chunksize size
Set the block size used when reading data from either files or channels. This value defaults to 4096.
-format string
Return the checksum using an alternative format template.
EXAMPLES
% crc::sum "Hello, World!"
37287
% crc::sum -format 0x%X "Hello, World!"
0x91A7
% crc::sum -file sum.tcl
13392
AUTHORS
Pat Thoyts
BUGS, IDEAS, FEEDBACK
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category crc of
the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for
either package and/or documentation.
SEE ALSO
cksum(n), crc32(n), sum(1)
KEYWORDS
checksum, cksum, crc, crc32, cyclic redundancy check, data integrity, security, sum
CATEGORY
Hashes, checksums, and encryption
COPYRIGHT
Copyright (c) 2002, Pat Thoyts <patthoyts@users.sourceforge.net>
crc 1.1.0 sum(n)