sha512sum.sh 383 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. check_command() {
  3. which "$1" >/dev/null 2>&1
  4. }
  5. if check_command sha512sum; then
  6. ret="$(sha512sum "$@")"
  7. elif check_command shasum; then
  8. ret="$(shasum -a 512 "$@")"
  9. elif check_command cksum; then
  10. ret="$(cksum -q -a sha512 "$@")"
  11. else
  12. echo "$0: no suitable sha512sum implementation was found" >&2
  13. exit 1
  14. fi
  15. [ "$?" -eq 0 ] || exit 1
  16. echo "$ret" | awk '{ print $1 }'