Skip to content

Instantly share code, notes, and snippets.

@lifning
Created October 9, 2012 02:50
Show Gist options
  • Save lifning/3856292 to your computer and use it in GitHub Desktop.
Save lifning/3856292 to your computer and use it in GitHub Desktop.
Quick and dirty script to get multiple types of checksum for a file.
#!/bin/bash
dir=$(mktemp -d)
cmd="cat \"${1}\" | tee"
shift
sums="md5 sha1"
if [ ! -z "${*}" ] ; then
sums="${@}"
fi
for i in ${sums} ; do
cmd="${cmd} >(${i}sum - > \"${dir}/${i}\")"
done
bash -c "${cmd} > /dev/null"
pushd "${dir}" > /dev/null
for i in ${sums} ; do
echo -ne "${i}\t: "
awk '{ print $1 }' < $i
done
popd > /dev/null
rm -r "${dir}"
@lifning
Copy link
Author

lifning commented Oct 9, 2012

I wrote this for the purpose of piping it into zenity in a Thunar action:
get-checksums.sh %f | zenity --text-info --width=500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment