Here's what I would start with, using "scratch" as the source and "zork" as the new copy (which could be on a different dist). Note that I'm using the -a
flag to cp
so that file timestamps are preserved during copy.
% (cd scratch ; tar cf - .) | shasum -a 256
a17cacd171d6cbc2f6da028c8167b0602a1146a337f602de71529999fe471e0f -
% /bin/cp -a scratch zork
% (cd zork ; tar cf - .) | shasum -a 256
a17cacd171d6cbc2f6da028c8167b0602a1146a337f602de71529999fe471e0f -
If you want to compare the two sums directly, you could use
if [[ $((cd scratch ; tar cf - .) | shasum -a 256) == $((cd zork ; tar cf - .) | shasum -a 256) ]]
then
echo match
else
echo no match
fi