I've created simple scripts to collect checksums for Unix operating system like linux or BSD.
I called it "multisum" but you can save the script with the name you like better. Just save them and place it anywhere in your $PATH.
The script uses an array (I know space seperated variables also works but I was too lazy and this was the first approach that came into my mind). So if you want to use something else than bash just modify the loop and the array variable.
Features:
* Display all checksums formatted uppercase
* display the complete size of the file in bytes
Requirements:
The only program you need to install beforehand is cksfv
Also check if md5, sha1 and sha256 for BSD and md5sum, sha1sum and sha256sum are installed. But I've never faced a unix system without them in the base installation.
Usage:
Code: Select all
multisum <FILENAME>
Unfortunately linux and BSD do not use the same checksum tool implementations so do not work exactly the same.
So I have two scripts (one for linux and one for [free]BSD).
linux:
Code: Select all
#!/bin/bash
CHECKSUMS=("cksfv" "md5sum" "sha1sum" "sha256sum");
for f in "${@}";
do
echo "${f}:";
for i in "${CHECKSUMS[@]}";
do
if [ "${i}" == "cksfv" ]
then
printf "crc32: ";
"${i}" "${f}" | grep -v "^;" | awk '{print toupper($NF)}';
else
printf "${i}: ";
"${i}" "${f}" | awk '{print toupper($1)}';
fi
done;
printf "Size: ";
ls -l "${f}" | awk '{ print $5 }';
done;
Code: Select all
#!/usr/local/bin/bash
CHECKSUMS=("cksfv" "md5" "sha1" "sha256");
for f in "${@}";
do
echo "${f}:";
for i in "${CHECKSUMS[@]}";
do
if [ "${i}" == "cksfv" ]
then
printf "crc32: ";
"${i}" "${f}" | grep -v "^;" | awk '{print toupper($NF)}'
else
printf "${i}: ";
"${i}" -q "${f}" | awk '{print toupper($1)}';
fi
done;
printf "Size: ";
ls -l "${f}" | awk '{ print $5 }';
done;