When I generate checksums for my files, I have to do a bit of extra work to get them formatted properly:
CHECKSUM="$(shasum "$file" | cut -b 1-40)" echo -n "$CHECKSUM" > "$file.sha"
This is to ensure that in the file, I only have the checksum itself (hence
cut) and that at the end of the file, there's no newline (hence
Validating the checksums also requires a bit extra work:
CHECKSUM="$(shasum "$file" | cut -b 1-40)" echo -n "$CHECKSUM" | diff - "$file.sha"
Is there an easier, more compact way of creating and validating checksums without storing the path? I prefer not to store the path in the checksum along with the file as it makes the files less portable IMO.