Skip to content

Instantly share code, notes, and snippets.

@baamenabar
Last active September 23, 2022 09:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baamenabar/7411d3774829590040d9 to your computer and use it in GitHub Desktop.
Save baamenabar/7411d3774829590040d9 to your computer and use it in GitHub Desktop.
in shell bash: Read a file, get the md5 checksum, save it in a variable, make a copy of the file with the hash,
#!/bin/bash
# http://stackoverflow.com/questions/3679296/only-get-hash-value-using-md5sum-without-filename
md5HASH=($(md5sum www/app/js/bundle.js| cut -d ' ' -f 1))
cp www/app/js/bundle.js www/app/js/bundle-$md5HASH.js;
# store in variable in file
echo "<?php define('HASH_EXT', '$md5HASH'); ?>" > www/app/inc/hash-bundle.php;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment