Format
cksum [–ciprtT]
[file …file …]
Description
cksum calculates
and displays a checksum for each input file.
A checksum is an error-checking technique used by many programs
as a quick way to compare files that have been moved from one location
to another to ensure that no data has been lost. It also displays the number
of 8-bit bytes in each file.
If you
do not specify any files on the command line, or if you specify –
as the file name, cksum reads the standard
input (stdin).
When
_UNIX03 is YES, the
cksum output has the
space-separated form:
checksum bytecount filename
When
_UNIX03 is unset or not YES, the
cksum output
has the tab-separated form:
checksum bytecount filename
If
the file operand is not specified, the path
name and its leading white space is omitted.
Read error messages
are controlled by the _UNIX03 variable.
- If cksum fails with a read error and
_UNIX03 is YES, it sends a diagnostic message to standard error, and
does not show a checksum for that file.
- If _UNIX03 is unset or not YES, cksum displays
the checksum up to that point and marks the output line with FSUM6199
[read error].
cksum continues processing files in
either case.
All other error messages are sent to standard
error (stderr).
Options
cksum can
calculate checksums in a variety of ways. The default is compatible
with the POSIX standard. You can specify other algorithms with the
following options. The POSIX standard does not recognize these algorithms;
they are provided for compatibility with the
UNIX sum command.
- –c
- Uses a standard 16-bit cyclic redundancy check (CRC-16).
- –i
- Uses the CCITT standard cyclic redundancy check (CRC-CCITT). Data
communication network protocols often use a cyclic redundancy check
to ensure proper transmission. This algorithm is more likely to produce
a different sum for inputs—the only difference is byte order.
- –p
- Uses the POSIXchecksum algorithm. This is the default.
- –r
- Enables the use of an alternate checksum algorithm that has the
advantage of being sensitive to byte order.
- –t
- Produces a line containing the total number of bytes of data read
as well as the checksum of the concatenation of the input files.
- –T
- Enables the autoconversion of tagged files.
Localization
cksum uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- LC_TYPE
- NLSPATH
See Localization for more
information.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Inability to open input file
- An error reading the input file
- Error turning off the autoconversion of the input file
- 2
- Unknown command-line option
Portability
POSIX.2, X/Open Portability Guide.
All
the listed options are extensions of the POSIX standard.
Related information
cmp, diff, ls, sum, wc