2013
01.02

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
The following two tabs change content below.

charlie root

VP of keeping it real / HNIC at pissedoffadmins.com
I bring the cold coffee.

Latest posts by charlie root (see all)

No Comment.

Add Your Comment