1

Is there a way to get shasum to only print the hash?

I know this can be achieved by piping the output to another program, e.g.

shasum something | cut -d' ' -f1

Is there a way to achieve this only using shasum, without having to pipe the result somewhere else?

0

No, shasum always prints the filename of the file that it computes the hash for, or - if it reads from standard input.

To avoid the pipe, you could use

perl -MDigest::SHA -e '$s=Digest::SHA->new(); $s->add(<>); print $s->hexdigest(),"\n"' filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.