One Day One Cmd

Place for playing with commands…

Day 88: $cmp command

ODOC: About cmp command

Compares two files and tells you what line numbers are different.

Syntax

cmp [-c] [-i N] [-l] [-s] [-v] firstfile secondfile

-c -> Output differing bytes as characters.

-i N -> Ignore differences in the first N bytes of input.

-l -> Write the byte number (decimal) and the differing bytes (octal) for each difference.

-s -> Write nothing for differing files; return exit statuses only.

-v -> Output version info.

firstfile -> First file that you wish to compare.

secondfile -> Second file that you wish to compare to.

Examples

praveen@praveen-desktop:~$cmp file1.txt file2.txt

Compares file1 to file2 and outputs results. Below is example of how these results may look.

praveen@praveen-desktop:~$file.txt file2.txt differ: char 1011, line 112

With Regards,
S. Praveen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: