04-12-2010
Difference between cksum and sum in unix
i get 2 different values when i give cksum and sum command. Are they 2 different algorithms? can someone explain how this is different
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I recently joined this forum and new to UNIX.
Is there any difference between UNIX operating system and UNIX open server? Please explain. (1 Reply)
Discussion started by: Manjit
1 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I know how to read a return code after executing a single command.
"echo $?". But I do not know how to sum the return code for a group of commands.
If I string 3 commands together and I do an echo $? all I get is the retunr code for the last command. Example below:
... (3 Replies)
Discussion started by: z1tt45uuprs7
3 Replies
3. Solaris
Hello,
I would like to process a sum on a file :
for exemple :
4
5
3
Sum is 12
I tried with the "+" but it doesn't seems to work on the sun or maybe I use a wrong syntax, my script is as follow:
---------------------------
export Value
export TotalValue
while read Valeur
do... (4 Replies)
Discussion started by: Cecile
4 Replies
4. Shell Programming and Scripting
hi,
I am trying to use the cksum feature in unix. when i make a call to it i get returned something along the lines of:
4603435 14 file3
how do i get the first part of this response only; i.e:
4603435
I'm trying to use at a way without the use of sed and creating temp... (4 Replies)
Discussion started by: leeRoberts2007
4 Replies
5. UNIX for Dummies Questions & Answers
Input
1 2N 2N
1 2N 2N
1 2N 2N
1 2N Ateus
1 3 Mobiles 3M-100
1 3 Mobiles 3M-100
1 3 Mobiles 3M-100
1 3GNET 3gnet
1 3GNET 3gnet
1 3GNET G2828
1 3GNET G2828
1 3GNET G2829
1 3GNET G2829
1 3GNET G2829
OutPut should be
3 2N 2N
3 3 Mobiles 3M-100
2 3GNET 3gnet (4 Replies)
Discussion started by: gagan2010
4 Replies
6. Shell Programming and Scripting
Hi Friends,
I have the following file
chr1 1 2
chr1 2 3
chr1 3 4
chr1 4 5
chr1 5 6
chr1 19 20
chr1 20 21
chr1 21 22
I want to compare the third column of record 1 to second column of next record and if the difference is zero, consider its third column and match it to next record... (4 Replies)
Discussion started by: jacobs.smith
4 Replies
7. Shell Programming and Scripting
Dears,
Good Day !
Plz; i want to sum-up two consecutive values inside one row, and put the summation in a new column.
here the input:
1 2
4 5
6 7
the output should be:
1 2 3
4 5 9
6 7 13
If someone can help me to solve my issue !
thx anyway.
Video tutorial on how to use... (5 Replies)
Discussion started by: Ala Alzyadat
5 Replies
8. UNIX for Dummies Questions & Answers
Hi would like to ask you guys any advise regarding my problem
I have this kind of data
file.txt
111111111,20
111111111,50
222222222,70
333333333,40
444444444,10
444444444,20
I need to get this
file1.txt
111111111,70
222222222,70
333333333,40
444444444,30
using this code I can... (6 Replies)
Discussion started by: reks
6 Replies
9. UNIX for Dummies Questions & Answers
I have the code for the below things..
File1 has the content as below
8859 0 subscriberCreate
18 0 subscriberPaymentMethodChange
1650 0 subscriberProfileUpdate
7668 0 subscriberStatusChange
13 4020100 subscriberProfileUpdate
1 4020129 subscriberStatusChange
2 4020307 subscriberCreate
8831... (5 Replies)
Discussion started by: Mahen
5 Replies
10. Shell Programming and Scripting
In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13.
I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (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)