Skip to content

Instantly share code, notes, and snippets.

@esbullington
Last active October 7, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esbullington/3105926 to your computer and use it in GitHub Desktop.
Save esbullington/3105926 to your computer and use it in GitHub Desktop.
Quick and easy command line script to compare sha1sum of a file and the sha1sum string (eliminates need to create a file)
[ $(sha1sum /path/to/file/to/check.txt | awk '{printf "%s", $1}') = "1a5091_SHA1_TO_CHECK_443234" ] && echo "Pass: sha1sum match" || echo "Warning: no match"
@esbullington
Copy link
Author

Oddly, there seems to be no easy way to compare an md5sum string with a calculated md5sum on Linux without creating a file (i.e., "md5sum -c /file/name"), so I use this script, which can be run directly on the command line (no need to create and run a separate bash file).

@esbullington
Copy link
Author

Updated md5sum to sha1sum, a more appropriate hashing algorithm for the present day.

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