Wednesday, April 27, 2022

[SOLVED] How to check the checksum through commandline?

Issue

I want to do something like this on commandline on my UNIX variant

if (shasum httpd-2.4.7.tar.bz2 == 19asdasdasd56462e44d61a093ea57e964cf0af05c0e) echo 'good to go'

I dont want to write a separate script text page just to check this.
This above thing is showing syntax error. But there must be a slick way to get around this?

How to do this?


Solution

shasum httpd-2.4.7.tar.bz2 |
  awk '$1=="19asdasdasd56462e44d61a093ea57e964cf0af05c0e"{print"good to go"}'

So normally you get this output from shasum

19asdasdasd56462e44d61a093ea57e964cf0af05c0e *httpd-2.4.7.tar.bz2

What my command does it is takes the first field $1, and compares it against your string. If the strings match, then awk prints "good to go".

Note that for anything other than sha-1, you need to specify your algorithm. For example, for sha 256, you can do:

shasum -a256 httpd-2.4.7.tar.bz2

The -a flag specifies the algorithm.



Answered By - Zombo
Answer Checked By - Cary Denson (WPSolving Admin)