sum | |
Author: | Ken Thompson |
Developer: | AT&T Bell Laboratories |
Operating System: | Unix, Unix-like, Inferno |
Platform: | Cross-platform |
Genre: | Command |
License: | coreutils GPLv3+ |
is a legacy utility available on some Unix and Unix-like operating systems. This utility outputs a 16-bit checksum of each argument file, as well as the number of blocks they take on disk.[1] Two different checksum algorithms are in use. POSIX abandoned sum
in favor of cksum.
The program is generally only useful for historical interest. It is not part of POSIX. Two algorithms are typically available: a BSD checksum and a SYSV checksum. Both are weaker than the already weak 32-bit CRC used by cksum.
The default algorithm on FreeBSD and GNU implementations is the BSD checksum. Switching between the two algorithms is done via command line options.[1]
The two commonly used algorithms are as follows.
The BSD sum, -r in GNU sum and -o1 in FreeBSD cksum:
The above algorithm appeared in Seventh Edition Unix.
The System V sum, -s in GNU sum and -o2 in FreeBSD cksum:
The utility is invoked from the command line according to the following syntax: sum [OPTION]... [FILE]...
with the possible option parameters being:
When no file parameter is given, or when FILE is, the standard input is used as input file.
Example of use:
Example of -s use in GNU sum:
Example of using standard input, -r and printf to avoid newline: