Easy Tutorial
❮ Linux Comm Setconsole Linux Comm Time ❯

Linux cmp Command

Linux Command Manual

The Linux cmp command is used to compare two files for differences.

When the two files being compared are identical, the command does not display any information. If differences are found, by default, it marks the first differing character and its line number. If no file names are specified or the given file name is "-", the cmp command will read data from the standard input device.

Syntax

cmp [-clsv][-i <number of characters>][--help][first file][second file]

Parameters:

Example

To determine if two files are identical, enter:

cmp prog.o.bak prog.o

This compares prog.o.bak and prog.o. If the files are the same, no message is displayed. If the files are different, the first differing position is shown; for example:

prog.o.bak prog.o differ: char 4, line 1

If the message "cmp: EOF on prog.o.bak" is displayed, the initial part of prog.o matches prog.o.bak, but there is additional data in prog.o.

Linux Command Manual

❮ Linux Comm Setconsole Linux Comm Time ❯