cmp Linux Commands

What is Linux cmp Command?

Explanation

cmp COMMAND:

cmp linux command compares two files and tells you which line numbers are different.

SYNTAX :


cmp [options..] file1file2

OPTIONS:


- c Output differing bytes as characters.
- l Print the byte number (decimal) and the differing byte values (octal) for each difference.
- s Prints nothing for differing files, return exit status only.

EXAMPLE:


  1. Compare two files:
    cmpfile1file2

    The above cmp command compares file1.php with file2.php and results as follows.
    file1.php file2.php differ: byte 35, line 3

  2. Compare two files output differing bytes as characters:
    cmp-cfile1.phpfile2.php

    The above cmp command compares file1.php with file2.php and results as follows.
    file1.php file2.php differ: byte 35, line 3 is 151 i 15

Ask Questions

Ask Question