I'm writing up a bash script to copy all the contents of a directory to somewhere else and verify with a checksum of all files. Everything seems to work except that the md5sum fails because it's missing one file.
Here is the copy command:
if [ ! -d "$DESTINATION" ]; then
mkdir $DESTINATION
fi
cp -R --copy-contents $SOURCE/* $DESTINATION &&
sleep 1
Here is the portion that checks the hash:
(find $SOURCE -type f -exec md5sum {} \; | sort -k 2 | cut -d ' ' -f 1 | md5sum | cut -d ' ' -f 1) > $SOURCE1CS
(find $DESTINATION -type f -exec md5sum {} \; | sort -k 2 | cut -d ' ' -f 1 | md5sum | cut -d ' ' -f 1) > $DEST1CS
There is a folder called "Arduino" which contains a bunch of other files. The file the command fails to copy is called "._Arduino". If it makes any difference, it is the first file at the top of the list. There are other files with that prefix which are included. There may also be other missing files, but I'm not sure. For now I can only find the one.
What am I missing that cp isn't doing?
Actually... I see now that -r and --copy-contents could be the problem. Should I be using -a instead?