Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal emj's Journal: Making sha1 hashes for backup and integrity checking..

This will link one hash to one file, so if two files have the same hash the latter will overwrite the formers name. Thanks to Perl oneliners and lost+found recovery for inspiration.

find -type f -print0 |
xargs -0 openssl sha1 |
perl -ne '
sub parsesha1{
$sha1=substr($_,-41,40);
$filename=substr($_,5,-44)
}

&parsesha1;

$file_hashes{$sha1}=$filename;

END{
foreach $hash (keys %file_hashes){
print "$hash:",$file_hashes{$hash},"\n"}
} '

This discussion has been archived. No new comments can be posted.

Making sha1 hashes for backup and integrity checking..

Comments Filter:

"Ninety percent of baseball is half mental." -- Yogi Berra

Working...