I want to generate the hash(es) of a file or folder, recursively, and store it onto a file. For performance reasons, want to skip the hash generation if file(s) already exist.
Command line:
./check.sh option checksums.md5 file_or_folder
Example code 1 inside script:
find "$3" -type f -print0 | xargs -0 -i sh -c "grep -Fq '{}' \"$2\" || md5sum '{}' >> \"$2\""
Example code 2:
find "$3" -type f -exec sh -c 'grep -Fq "echo $1 && $@" \"$2\" || md5sum "$@" >> \"$2\"' - {} +
The problem is, if in find path there are special characters, doesn't work. Example:
"$3"="movies/Joe's-[Grym].(@BTT)/Skidrow-$USER&.(@BK NET).MKV"
Could you help me fix it, with find
or any other command?