Created
April 3, 2022 11:04
-
-
Save bedekelly/83d4da5b4a14e6681c289085c8c8596d to your computer and use it in GitHub Desktop.
Rehash CSS files and replace their occurrences in HTML files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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