A method of MD5 the Linux system to generate the files in the directory recursively

Source: Internet
Author: User
Tags md5 php script

This article mainly introduces the Linux system recursive generation directory file MD5 method, using PHP script implementation, the need for friends can refer to the

Linux uses md5sum recursively to generate the entire directory MD5

Today to use the md5sum operation directory, recursive generation of all the files in the directory MD5 value, the results found that it does not support recursive operations and then wrote a PHP script to deal with

Code:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The

Note: There are two spaces between the generated MD5 value and the file, or the following error occurs

The code is as follows:

Md5sum:file1.md5:no properly formatted MD5 checksum lines

In a simpler, use Linux Find command a sentence to fix

Code:

?

1 Find/data/www/bbs/source-type f-print0 | xargs-0 md5sum > File2.md5

Test

?

1 2 Md5sum-c file1.md5 md5sum-c FILE2.MD5

As shown in the figure

This prints all of the test results to the screen, and if the last one shows such information md5sum:warning:2 of 1147 computed checksums did not match indicates that 2 of the total 1147 articles are not compliant

And then we can

?

1 Md5sum-c FILE1.MD5 | grep FAILED

It's easy to know which files have been tampered with.

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.