– -v option : This gives the output information and exits.ĩ.
*indicating files are identical for startingĨ. n option :This option allows you to limit the number of bytes you want to compare ,like if there is only need to compare at most 25 or 50 bytes. This gives an exit value of 0 if the files are identical, a value of 1 if different, or a value of 2 if an error message occurs. s option : This allows you to suppress the output normally produced by cmp command i.e it compares two files without writing any messages. The second column represents the byte value of the differing byte in the first file, while the third column represents the byte value of the differing byte in the second file.ĥ. The first column in the output represents the position (byte number) of differing bytes. l option : This option makes the cmp command print byte position and byte value for all differing bytes. i : :This option is very much similar to the above -i option but with the difference that now it allows us to input the number of bytes we want to skip from both the files separately.Īfter 10 bytes skipped from first file andĤ. Note that in cases like these (where you use -i to skip bytes), the byte at which the comparison begins is treated as byte number zero.ģ. *indicating that both files are identicalĪfter 10 bytes skipped from both the files*/ This can be done by specifying the number of bytes as argument to the -i command line option. i : Now, this option when used with cmp command helps to skip a particular number of initial bytes from both the files and then after skipping it compares the files. The values 154 and 151 in the above output are the values for these bytes, respectively.Ģ. * indicating that the difference is in 12īyte ,which is 'l' in file1.txt and 'i' in file2.txt.*/ .cmp command used with -b option.//įile1.txt file2.txt differ: 12 byte, line 2 is 154 l 151 i b(print-bytes) : If you want cmp displays the differing bytes in the output when used with -b option. ISRO CS Syllabus for Scientist/Engineer Examġ.ISRO CS Original Papers and Official Keys.GATE CS Original Papers and Official Keys.