Skip to content

Instantly share code, notes, and snippets.

@bedekelly
Created April 3, 2022 11:04
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 bedekelly/83d4da5b4a14e6681c289085c8c8596d to your computer and use it in GitHub Desktop.
Save bedekelly/83d4da5b4a14e6681c289085c8c8596d to your computer and use it in GitHub Desktop.
Rehash CSS files and replace their occurrences in HTML files.
for file in projects shared style
do
# Move the file to a name matching its hash.
echo mv css/$file*.css css/$file-`minihash css/$file*.css`.css
mv css/$file*.css css/$file-`minihash css/$file*.css`.css
# Grab the new filename and replace all occurrences in HTML files.
filePath=`ls css/$file-*.css`
newFile="$(basename $filePath)"
echo $filePath $newFile
sed -i '.bak' -e "s/$file-[^.]*\.css/$newFile/g" *.html
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment