md5sum & sha1sum from zshrc

i just added this quick little function just to give me a quick output when attaching to emails:

function checksum() { printf "FILE: `echo ${1}`\n" ; printf "SIZE: `ls -al ${1} | awk '{ print $5 }'` bytes\n" ; printf "MD5 : `md5sum ${1} | awk '{ print $1 }' | tr '[:lower:]' '[:upper:]'`\n" ; printf "SHA1: `sha1sum ${1} | awk '{ print $1 }' | tr '[:lower:]' '[:upper:]'`\n" }

or broken down for legibilities sake:

function checksum() { 
    printf "FILE: `echo ${1}`\n" ; 
    printf "SIZE: `ls -al ${1} | awk '{ print $5 }'` bytes\n" ; 
    printf "MD5 : `md5sum ${1} | awk '{ print $1 }' | tr '[:lower:]' '[:upper:]'`\n" ; 
    printf "SHA1: `sha1sum ${1} | awk '{ print $1 }' | tr '[:lower:]' '[:upper:]'`\n" } 

here is what the output looks like:

% checksum .gitconfig 
FILE: .gitconfig
SIZE: 79 bytes
MD5 : FCB97FF8A0B5851E08DF593411DD446A
SHA1: 38F06AC8067BEFDF84827686409260B28CB45C7C
«
»

    Leave a Reply

    Your email address will not be published. Required fields are marked *