Automated Checksums
I'm creating some checksums today for a folder full of large files.
This is the method, which I found on the ubuntu forums. Essentially md5sum is called on each file with 'find -exec' :
find -type f -exec md5sum "{}" \; > md5sum.txt
' find ' returns the contents of the directory, ' -type f ' ensures only regular files are returned, I'm not sure what the ' "{}" \;' part is for, finally I added '> md5sum.txt' to send the output to a file.
This call can take a very long time depending on the size of files it is being called on, so I checked up on it by counting the lines in md5sum.txt with the following command:
cat md5sum.txt | nl | tail -1 | cut -f 1
What this does is list the entire md5sum.txt file, count each line with 'nl', output only the last line (aka first from the end) with 'tail -1' then return only the first field of that line with 'cut -f 1'
Finally, once md5sum.txt has been generated the files can be checked using the ' -c ' flag:
md5sum -c md5sum.txt
This is the method, which I found on the ubuntu forums. Essentially md5sum is called on each file with 'find -exec' :
find -type f -exec md5sum "{}" \; > md5sum.txt
' find ' returns the contents of the directory, ' -type f ' ensures only regular files are returned, I'm not sure what the ' "{}" \;' part is for, finally I added '> md5sum.txt' to send the output to a file.
This call can take a very long time depending on the size of files it is being called on, so I checked up on it by counting the lines in md5sum.txt with the following command:
cat md5sum.txt | nl | tail -1 | cut -f 1
What this does is list the entire md5sum.txt file, count each line with 'nl', output only the last line (aka first from the end) with 'tail -1' then return only the first field of that line with 'cut -f 1'
Finally, once md5sum.txt has been generated the files can be checked using the ' -c ' flag:
md5sum -c md5sum.txt
Comments
Post a Comment