Full-stack web applications developer

Calculating a checksum for directory

October 2, 2019Arthur Pemberton0 Comments

Are you in need in calculating a checksum for the contents of a directory? This sequence of commands can help.

find /etc/haproxy/ -type f | sort | xargs -L 1 -d '\n' sha1sum | sha1sum

In the above example, the files in the HAProxy config directory were used to come up with a single checksum. I used this as part of a shell script to compare a local copy of the directory with a lsyncd synchronized version of that directory on a remote machine.

In the above example, sha1sum was used, but any similar checksuming executable could be used.

Leave a Reply