Comparing Files - cmp Assignment Help

Assignment Help: >> Unix Files and Directories - Comparing Files - cmp

Comparing Files

Normally, several new files are created in during the course of updating older files. Several versions of the similar file with slight differences in the content are maintained.  At a few point of time, it becomes extremely hard to keep track of the files and it becomes essential to cleanup the directories through removing the unwanted older versions.

There are utilities in UNIX which can be used to compare the contents of two files to see if they are similar. The nature of the difference can be determined if they are not.

cmp

This command is used to compare two files. That compares two files and shows the first example where the files differ. cmp returns no output if there is no difference.

Syntax

cmp file1 file2

In the given syntax file1 and file2 are the files to be compared.

Practice 1

The following instance displays the usage of the cmp command.

# cat > myfile

This is a description of cmp command

^D

# cat > yourfile

This is the description of cmp command

^D

# cmp myfile yourfile

myfile yourfile differ: char 9, line 1

In the given example the cmp command reports that the two files differ in the ninth character of the document, located in line 1.

Note: cmp indicates only the first character in which the files differ. cmp reports the difference on a character through character basis.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd