I need to create a list of checksums of the files that are inside a directory, including any subdirectories.

The command that I try to execute is the following:

 sha256sum -b * 


 -b = Read in Binary.

 * = Specifies that you must verify all file extensions.

With the command I get the following output:

sha256sum: test0: Is a directory e3d748fdf10adca15c96d77a38aa0447fa87af9c297cb0b75e314cc313367daf *test1.txt db0c7a354881fe2dd1b45642a68f6a971c7421e8fdffe56ffa7c740111e07274 *test2.txt

Instead of reporting that test0 is a directory, you should also generate the checksum of the content.

Do you recommend always using -b in any type of file? In what cases should -t be used?

Is it possible to filter the types of files I want to omit in the verification, without having to add all the files I want to admit? What command should I execute?

I looked for help but I do not find anything related.

| improve this question | | | | |

You can use find to find all files in the directory tree, and let it run sha256sum. The following command line will create checksums for the files in the current directory and its subdirectories.

find . -type f -exec sha256sum {} \;

I don't use the options -b and -t, but if you wish, you can use -b for all files. The only difference that I notice is the asterisk in front of each file name.

| improve this answer | | | | |
  • Excellent! And why should we add find instead of containing the option within the same sha256sum program? Does this usually happen? – MarianoM Nov 9 '18 at 8:48
  • Now I do not understand the use of the curly braces {} well. I was reading a bit more but I found that "it can be used as a placeholder for each file that locates the search command" what does that mean? Does it refer to the coloring of the text or some other reason? I tried inserting a route / test and accepted it. This confuses me even more. It's just a curiosity to learn more about the parameters used. – MarianoM Nov 9 '18 at 8:52
  • Using find is a good way to find files in subdirectories, and with the -exec option it is possible to run commands with parameters {}. Each file found by find will be replacing the spaceholder {}, so in your case sha256sum will work on each of the files one after another. – sudodus Nov 9 '18 at 8:53
  • Thank you so much for everything. As a clarification, due to tests that I was doing, if this command is going to be used; you should not use the -b option if you do not want to have to edit the text later because when you run (sha256sum -c) you can not find the path of the files. However, I wonder if there will be a difference between using -b or not. – MarianoM Nov 9 '18 at 12:01
  • I think the asterisk (*) in the output is the only difference. Maybe (I am guessing here) long ago there was some difference (that some characters in binary files could create problems like truncation of the process). – sudodus Nov 9 '18 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.