Skip to content

Instantly share code, notes, and snippets.

@temoto
Created February 18, 2016 10:21
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 temoto/ae5ee4117f2660f7e7ce to your computer and use it in GitHub Desktop.
Save temoto/ae5ee4117f2660f7e7ce to your computer and use it in GitHub Desktop.
[website deploy] Find references to missing assets files. Helps to prevent 404 and 500 (pagespeed beacon) errors.
#!/bin/bash
set -e
find . -print0 |fgrep -v --null-data --null '/.hg/' >tmp-asset-clean-all
egrep -hIor "/\w+/\w+\.(gif|jpg|jpeg|png|eot|svg|ttf|woff|webm|webp)" |sort -u >tmp-asset-clean-refs
for f in $(cat tmp-asset-clean-refs); do
dir=${f%%/*}
name=${f##*/}
if ! egrep --max-count=1 --null-data -q $f tmp-asset-clean-all; then
echo -e "\n\n$f not found. References:\n $(egrep -Inr $f)\n\n"
fi
done
rm -f tmp-asset-clean*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment