Compare two different files in Ubuntu

Source: Internet
Author: User
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 ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.