Skip to content

Instantly share code, notes, and snippets.

@alpha1125
Created March 24, 2020 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alpha1125/45072f4a06afd63af34f3714a5205c6a to your computer and use it in GitHub Desktop.
Save alpha1125/45072f4a06afd63af34f3714a5205c6a to your computer and use it in GitHub Desktop.
Bash script to fetch the sha256 value from a given string.
#!/usr/bin/env bash
string="9988776: digest: sha256:994d99f0d06024acfeb99bb393dc9907d80d6bf5b49e29e313a037580f1a9b07 size: 1337"
echo "the sha is: $string" | sed 's/.*digest: sha256:\([a-f0-9]*\) size:.*/\1/'
## echo's out 994d99f0d06024acfeb99bb393dc9907d80d6bf5b49e29e313a037580f1a9b07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment