0
 $ [[ $(sha256sum _downloaded_file_ | cut -d' ' -f 1) == $(grep -Po '\b[a-zA-Z0-9]{64}\b' _checksum_fle_) ]] && printf "\033[0;32mGood" || printf "\033[0;31mBad"

Dec. 13, 2019, 8:10 p.m.ratfink417

Explanation

  • replace downloaded_file with the path to the file you want to hash

  • replace _checksum_file with the path to the file that lists the sha256 you should match

Limitations

You could pretty easily adapt thin for md5 or whatever algorithm you wanna use just change the character count in the grep at the beginning.

You could probably improve on this by having it check the length of the key listed in the dist-file and have it run different checks based on the character count of a line that it finds in the file... i couldn't come up with a way to do that without this not truly being a one-liner anymore though