Skip to content

Instantly share code, notes, and snippets.

@cyber-murmel
Created May 17, 2020 14:28
Show Gist options
  • Save cyber-murmel/8f9eadeeb41a3dfcd4de6d66b0feeb7f to your computer and use it in GitHub Desktop.
Save cyber-murmel/8f9eadeeb41a3dfcd4de6d66b0feeb7f to your computer and use it in GitHub Desktop.
recursive file integrity checking using openssl dgst

Recursive File Integrity Checking using openssl dgst

Checksumming

Use find to iterate trought all subdirectories of the given path (./). openssl dgst -sha256 each file in each directory and add the output to the SHA256 file in the corresponding directory.

find ./ -type d -exec sh -c 'cd "{}"; find ./ -maxdepth 1 -type f -not -name SHA256 -exec openssl dgst -sha256 \{\} + | sort -u | tee SHA256' \;

Checking

openssl dgst -sha256 each file in each directory and try to find the checksum in the SHA256 file.

find ./ -type d -exec sh -c 'cd "{}"; find ./ -maxdepth 1 -type f -not -name SHA256 -exec openssl dgst -sha256 \{\} + | grep -o "[0-9a-f]\{64\}" | grep -f - SHA256 -q || echo "$(</dev/stdin) not found in SHA list"' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment