What flags do I need to give to the find
command to enter the directory before running the -exec
command?
I have a directory filled with directories filled with files
> root directory
-> directory1
-> file1
-> file2...
-> directory2
->file1
->file2
-> directory...
and I want to place a checksum file in each directory which contains the sums of the directory contents:
> root directory
-> directory1
-> file1
-> file2...
-> checksums.md5
-> directory2
->file1
->file2
-> checksums.md5
-> directory...
I've been fiddling around along the lines of
find . -type f -name '*' -exec md5sum {} >> checksums.md5 \;
but it places the checksum file in the root directory (the starting point), plus the file contains the hash of all the files. I have tried using the -execdir
flag to no use.
What I'm trying to do is to MD5 the contents of each folder and place the checksum file inside it, then move on to the next folder and repeat.
The contents of the checksums.md5 file should also preferably be sorted.