Sometimes you will receive a file with the same file name as the file in your hand sent by a colleague. But how do you know whether the file has been modified? You can check the file size, but this method is not reliable, because your colleagues may have added some content, but you may have deleted the content of the same size. There are two simple methods to compare files under the command line in Ubuntu. The first is the "md5sum" command, which can generate a separate 32-bit verification number based on the file content. You can compare the md5sum output of the two files.
Sometimes you will receive a file with the same file name as the file in your hand sent by a colleague. But how do you know whether the file has been modified? You can check the file size, but this method is not reliable, because your colleagues may have added some content, but you may have deleted the content of the same size.
There are two simple methods to compare files under the command line in Ubuntu. The first is the "md5sum" command, which can generate a separate 32-bit verification number based on the file content. You can compare the md5sum output of the two files to check whether the files are the same. Run the md5sum command, enter "md5sum filename1", and then enter "md5sum filename2 ".
Md5sum is more suitable for small files than for large files because it takes some time to generate verification codes. Another method is to use the "diff" command. You only need to enter "diff filename1 filename2 ". If the two files are the same, there is no output. If there is a difference, you may have one of the following two things: one piece of information, showing "binary files filename1 and filename2 differ" (if you compare two Word documents ); in addition, the display of a line on the screen is different (This Is What diff thinks you are comparing a text file ).