[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5

sum Command

Purpose

Displays the checksum and block count of a file.

Syntax

sum [ -i ] [ -r ] [ -o ] [ File ... ]

Description

The sum command reads the file specified by the File parameter and calculates a checksum and the number of 1024-byte blocks in that file. If no options are specified, a byte-by-byte algorithm, such as the BSD 4.3 default algorithm, is used. If no files are named, the standard input is read. The checksum and number of 1024-byte blocks are written to standard output. The sum command is generally used to determine if a file that has been copied or communicated over transmission lines is an exact copy of the original.

Flags

-i Allows the user to compute the checksum without including header information, if the input file is a binary file. If the input file is not a binary file, the checksum includes header information.
-o Uses the word-by-word algorithm to compute the checksum. The sum command with the -o flag is compatible with the Version 2 sum command in terms of the checksum, but not the number of blocks.
-r Uses a byte-by-byte algorithm to compute the checksum. Using the -r flag is the same as using no options.
Note
The default is no longer the word-by-word computation algorithm; it is the BSD 4.3 default algorithm.

Exit Status

This command returns the following exit values:

0 Successful completion.
>0 An error occurred.

Examples

To display the checksum of, and the number of 1024-byte blocks in, the file1 and file2 files, type:

sum file1 file2

If the checksum of the file1 file is 32830, the checksum of the file2 file is 32481, and the file1 file contains one block, and the file2 contains four blocks, the sum command displays:

32830           1       file1
32481           4       file2

Files

/usr/bin/sum Contains the sum command.

Related Information

The cksum command, wc command.

The File Systems in AIX 5L Version 5.2 System Management Concepts: Operating System and Devices gives an explanation of what a file system is and why to use one.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]