Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the checksum through commandline?

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?

like image 871
John Doe Avatar asked Feb 22 '14 16:02

John Doe


People also ask

How do I run checksum on Linux?

To run a checksum on a file is simple. Just evoke md5sum followed by the name of the file. Here we generated a checksum of a text file containing all 185 lines of the short story Harrison Bergeron by Kurt Vonnegut. If we edit the file and change one character, the checksum will change.


1 Answers

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.

like image 146
Zombo Avatar answered Sep 17 '22 13:09

Zombo