[Previous] [Contents] [Next]

cksum

Display file checksums and block counts (POSIX)

Syntax:

cksum [[-9|-12] | -o algorithm] [-q | -v] [file...]

Options:

-9
Deprecated. Use the algorithm from Draft 9.
-12
("twelve") Deprecated. Use the algorithm from Draft 12
-o algorithm
Use the specified algorithm.
Algorithm:  Action:
1 Use historic 16-bit checksum algorithm.
2 Use historic 32-bit checksum algorithm.
9 Use 1003.2 draft 9 algorithm (QNX 4.0)
11 Use 1003.2 draft 11 algorithm
12 Use 1003.2 draft 12 algorithm
92 Use 1003.2-1992 standard algorithm (Default)
4.1 Use old QNX cksum algorithm (QNX 4.10-4.21)
-q
Quiet. Do not display header (counteracts -v). (Default)
-v
Verbose. Display a header which states the algorithm used and names the output columns.
file
The pathname of a file to be checked. If no files are specified, the standard input is used.

Note:

All the options to cksum are QNX extensions to the POSIX 1003.2 cksum.


Description:

The cksum utility writes one line to standard output for each file you specify. This line will contain the checksum of the file, as well as the file size and the name of the file being checked. The format of this output varies slightly depending on the command-line options specified to cksum as follows:

-o algorithm: Filesize units: Output format:
1 k bytes %lu %lu %s
2 512-byte blocks %lu %lu %s
all others bytes %10lu %10lu %s

If you don't specify any files, cksum processes standard input; no filename is given in the output line.

The cksum utility lets you quickly compare a suspect version of a file to a trusted version of the same file. You can also use cksum to check files after they have been transferred by modem, restored from backup media, or unpacked from a compressed form. The utilities that perform these operations have their own checks, but cksum serves as a useful independent checking mechanism.

If you wish to perform a byte-by-byte comparison of files, you can use the cmp utility.

Examples:

Report the checksum of the file archive.tar.F:

cksum archive.tar.F

Files:

The data to be used for the checksum calculations are read from standard input if no file is specified on the command line. If files are specified, cksum will open and read from those files and the standard input will not be used.

The results of the calculations are written to standard output in the format detailed above in the cksum description.

Errors encountered during execution will result in diagnostic messages being written to standard error.

Environment variables:

CKSUM
default command-line option to use for checksums. This environment variable is supported to remedy those situations where a recent version of the cksum utility must be installed in an older system which has an abundance of programs which rely on the pre-QNX 4.2 default output. The use of this environment variable is deprecated, and it may be dropped in a future release.

Exit status:

0
All files were processed successfully.
>0
An error occurred.

See also:

cmp, diff, wc


[Previous] [Contents] [Next]