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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With