I have several exports of telegram data and I would like to calculate the md5 and sha256 hash of all files but it only calculates those in the root directory
$ md5sum `ls` > hash.md5
md5sum: chats: Is a directory
md5sum: css: Is a directory
md5sum: images: Is a directory
md5sum: js: Is a directory
md5sum: lists: Is a directory
md5sum: profile_pictures: Is a directory
This is in the output file
7e315ce28aa2f6474e69a7b7da2b5886 export_results.html
66281ec07a2c942f50938f93b47ad404 hash.md5
da5e2fde21c3e7bbbdb08a4686c3d936 ID.txt
There is a way to get something like this out?
5750125fe13943f6b265505b25828400 js/script.js
Sorry for my english
3
Answers
With bash:
Ignore errors of the kind:
md5sum: foobar: Is a directory
From
man bash
:Alternatively, you can use
find
with-exec
option:Replace the
topdir
with the actual directory name, or drop it if you want to work on the current directory (and its subdirectories, if any). This will only compute the checksums of regular files (so, no "md5sum: something: Is a directory" errors), and won’t suffer from the "argument list too long" problem.A tool which helps, but might not be installed by default, is
hashdeep
.hashdeep
does it directly and has some more advantages, e.g. binary is available for Windows, too.Your question would be answered using
hashdeep
with this command:This calculates md5 and sha256 of all files in all subdirs with one command.
Creating md5 and sha256 together might be faster due to caching effects of the files. Additionally the command has an option to use multiple threads, which could fasten up the task with multi-core CPUs and fast disks.