Skip to content

Instantly share code, notes, and snippets.

@GitMirar
Last active May 22, 2020 10:14
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 GitMirar/b732317f8861f36a1af0a8953d945dd9 to your computer and use it in GitHub Desktop.
Save GitMirar/b732317f8861f36a1af0a8953d945dd9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# rename binaries after their sha256 sum
function rename_sha256 {
sha256=`sha256sum "${1}" | sed 's/ .*$//'`
oldPath=`readlink -f "$1"`
directory=`echo ${oldPath} | sed 's/\(.*\)[/].*/\1/'`
newPath="${directory}/${sha256}"
echo "$oldPath -> $newPath"
mv "${oldPath}" "${newPath}"
}
for arg in "$@"
do
rename_sha256 "${arg}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment