Google News
logo
Unix - Quiz(MCQ)
Which command is used for comparing two files?
A)
diff
B)
cmp
C)
comp
D)
comm

Correct Answer :   cmp


Explanation : cmp command is used for comparing two files byte by byte. It displays the first mismatch and its location on the terminal. It does not bother about subsequent mismatches but displays only the first mismatch. As soon as the first difference is found, the command terminates and outputs the line and byte in which there is a difference. For example,

$ cmp  file01  file02
file01  file02 differ: Byte 20, Line 2​

diff command is used for converting one file into another in order to make them identical and comm is used for displaying the common elements in both the files.

Advertisement