I am writing a script for Mac OS X Lion 10.7 and I would like to know how I can search for files based on their SHA1 hashes. I would like to search the whole file system for the file(s) I will be looking for.
For example the SHA1 value 0d882ff2d5edd7d045c1b57320d2e046793868f8
corresponds to the file MacOSXUpdCombo10.7.2.dmg
How can I search the hard drive for the file with its SHA1 value without needing to compare the file?
Best Answer
You can use the
find
command:However, since you're running this on all files, it may be extremely slow — try limiting the search directory by replacing
/
with the path to a specific directory you want to search.