These commands generate just a few numbers representing entire contents of files.
wc
: Print byte, word, and line counts
wc
counts the number of bytes, whitespace-separated words, and
newlines in each given file, or standard input if none are given
or for a file of `-'. Synopsis:
wc [option]... [file]...
wc
prints one line of counts for each file, and if the file was
given as an argument, it prints the file name following the counts. If
more than one file is given, wc
prints a final line
containing the cumulative counts, with the file name `total'. The
counts are printed in this order: newlines, words, bytes.
By default, wc
prints all three counts. Options can specify
that only certain counts be printed. Options do not undo others
previously given, so
wc --bytes --words
prints both the byte counts and the word counts.
The program accepts the following options. Also see section Common options.
sum
: Print checksum and block counts
sum
computes a 16-bit checksum for each given file, or
standard input if none are given or for a file of `-'. Synopsis:
sum [option]... [file]...
sum
prints the checksum for each file followed by the
number of blocks in the file (rounded up). If more than one file
is given, file names are also printed (by default). (With the
`--sysv' option, corresponding file name are printed when there is
at least one file argument.)
By default, GNU sum
computes checksums using an algorithm
compatible with BSD sum
and prints file sizes in units of
1024-byte blocks.
The program accepts the following options. Also see section Common options.
sum
. Unless `-s' was also
given, it has no effect.
sum
's default, and print file sizes in units of 512-byte blocks.
sum
is provided for compatibility; the cksum
program (see
next section) is preferable in new applications.
cksum
: Print CRC checksum and byte counts
cksum
computes a cyclic redundancy check (CRC) checksum for each
given file, or standard input if none are given or for a
file of `-'. Synopsis:
cksum [option]... [file]...
cksum
prints the CRC checksum for each file along with the number
of bytes in the file, and the filename unless no arguments were given.
cksum
is typically used to ensure that files have been
transferred by unreliable means (e.g., netnews) have not been corrupted,
by comparing the cksum
output for the received files with the
cksum
output for the original files (typically given in the
distribution).
The CRC algorithm is specified by the POSIX.2 standard. It is not
compatible with the BSD or System V sum
algorithms (see the
previous section); it is more robust.
The only options are `--help' and `--version'. See section Common options.
md5sum
: Print or check message-digests
md5sum
computes a 128-bit checksum (or fingerprint or
message-digest) for each specified file.
If a file is specified as `-' or if no files are given
md5sum
computes the checksum for the standard input.
md5sum
can also determine whether a file and checksum are
consistent. Synopsis:
md5sum [option]... [file]... md5sum [option]... --check [file] md5sum [option]... --string=string ...
For each file, `md5sum' outputs the MD5 checksum, a flag indicating a binary or text input file, and the filename. If file is omitted or specified as `-', standard input is read.
The program accepts the following options. Also see section Common options.
md5sum
is usually the output of
a prior, checksum-generating run of `md5sum'.
Each valid line of input consists of an MD5 checksum, a binary/text
flag, and then a filename.
Binary files are marked with `*', text with ` '.
For each such line, md5sum
reads the named file and computes its
MD5 checksum. Then, if the computed message digest does not match the
one on the line with the filename, the file is noted as having
failed the test. Otherwise, the file passes the test.
By default, for each valid line, one line is written to standard
output indicating whether the named file passed the test.
Use the `--status' option to inhibit that output.
If any listed file cannot be opened or read, if any valid line has
a MD5 checksum inconsistent with the associated file, or if no valid
line is found, exit with a non-zero status. Otherwise, exit successfully.