Tuesday, May 7, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 3056  / 2 Years ago, fri, july 29, 2022, 5:44:54

I've been using the following command line to do recursive checksumming of directories. It seems to get the job done, but still being a newbie I've been wondering, are there any potential problems with doing it this way? Is it possible for this command to miss files or otherwise mess up?



find ./dir/ -type f -exec sha1sum {} ; > files.sha1

More From » command-line

 Answers
7

There's nothing wrong I can see with your approach. You're excluding directories and find will include hidden files by default. Yeah, it's fine.



But I'll offer you an alternative because that's what I do:



shopt -s globstar dotglob
sha1sum **


globstar enables a recursive match for ** and dotglob enables matching hidden files. Between them they expand to all the filenames and sha1sum can parse them all.



The main problem with this approach is it will pass all the filenames off to sha1sum in one fat pile. While this can be somewhat faster at small loads, it will explode if you have too many filenames. I don't know what the cut-off is.


[#26332] Sunday, July 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luringdge

Total Points: 3
Total Questions: 126
Total Answers: 109

Location: India
Member since Sun, Feb 6, 2022
2 Years ago
;