Unable to create the md5sum file I need to create. Manually doing it would be far too labour-intensive

StackOverflow https://stackoverflow.com/questions/13760928

I need to create/recreate an md5sum file for all files in a directory and all files in all sub-directories of that directory.

I am using a rockettheme template that requires a valid md5sum document and I have made changes to the files, so the originally included md5sum file is no longer valid.

There are over 300 files that need to be checksummed, and the md5hash added to a single file.

The basic structure of the file is as follows:

1555599f85c7cd6b3d8f1047db42200b admin/forms/fields/imagepicker.php
8a3edb0428f11a404535d9134c90063f admin/forms/fields/index.html
8a3edb0428f11a404535d9134c90063f admin/forms/index.html
8a3edb0428f11a404535d9134c90063f admin/index.html
8a3edb0428f11a404535d9134c90063f admin/presets/index.html
b6609f823ffa5cb52fc2f8a49618757f admin/presets/preset1.png
7d84b8d140e68c0eaf0b3ee6d7b676c8 admin/presets/preset2.png
0de9472357279d64771a9af4f8657c2a admin/presets/preset3.png
5bda28157fe18bffe11cad1e4c8a78fa admin/presets/preset4.png
2ff2c5c22e531df390d2a4adb1700678 admin/presets/preset5.png
4b3561659633476f1fd0b88034ae1815 admin/presets/preset6.png
8a3edb0428f11a404535d9134c90063f admin/tips/index.html
2afd5df9f103032d5055019dbd72da38 admin/tips/overview.xml
79f1beb0ce5170a8120ba65369503bdc component.php
caf4a31db542ca8ee63501b364821d9d css/grid-responsive.css
8a3edb0428f11a404535d9134c90063f css/index.html
8697baa2e31e784c8612e2c56a1cd472 css/master-gecko.css
0857bc517aa15592eb796553fd57668b css/master-ie10.css
a4625ce5b8e23790eacb7704742bf735 css/master-ie8.css

This is just a snippet, but the logic is there.

hash path/to/file/relative/to/MD5SUM_file

Can anyone help me write a shell script (bash shell) that I can add to my path that will execute and generate a file called "MD5SUM_new"? I want the output file name to be "MD5SUM_new" so I can review the content before issuing a mv MD5SUM_new MD5SUM

FYI, the MD5SUM_new file needs to be saved in the root level of the template.

Thanks

有帮助吗?

解决方案

This is quite easy, really. To hash all files under the current directory:

find . -type f | xargs md5sum > md5sums

Then, you can make sure it's correct:

md5sum -c md5sums
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top