Handy scripts you'd like to share

For a while I have been typing out a one-liner for verifying ISO checksums like this:

sha256sum garuda-cinnamon-linux-zen-230501.iso > temp.txt && meld temp.txt garuda-cinnamon-linux-zen-230501.iso.sha256 && rm temp.txt

It works fine, but if I am testing a batch of ISOs I do get tired of typing it over and over so I turned it into a simple Bash script.

#!/bin/bash

# Check for a valid number of arguments
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
    echo "Usage: $0 <file1> <file2> [shasum]"
    exit 1
fi

file1="$1"
file2="$2"
shasum_type="${3:-sha256sum}"

# Calculate the checksum of file1 and save it to a temporary text file
"$shasum_type" "$file1" > shasumchecker_tempfile.txt

# Open Meld to compare the checksum file and file2
meld shasumchecker_tempfile.txt "$file2"

# Clean up the temporary file
rm shasumchecker_tempfile.txt

You run it like this:

./shasumchecker.sh [ISO file] [sha256 file]

It calculates the shasum of the ISO file, saves it as a temporary text file, then opens the text file and the sha256 file in Meld so you can see if they match or not.

After you close Meld, it deletes the temporary text file.

It defaults to using sha256sum because that’s what we use here with Garuda Linux, but the script will accept a third argument if you want to use a different kind of shasum. For example:

./shasumchecker isofile shafile sha512sum

This will run the script with sha512 instead of sha256.

Throw the script on your Ventoy so you have it handy next time you are ISO testing. :wink:

5 Likes