Skip to content

Instantly share code, notes, and snippets.

@elico
Created July 18, 2016 15: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 elico/ac58073812b8cad14ef154d8730e22cb to your computer and use it in GitHub Desktop.
Save elico/ac58073812b8cad14ef154d8730e22cb to your computer and use it in GitHub Desktop.
Add CDN HIT notation
#!/usr/bin/env bash
HEADERSDIR=/opt/dir/
function add() {
grep -H "X-SHMSCDN: HIT" $1 || perl -pi -e '$/="";s/\r\n\r\n/\r\nX-SHMSCDN: HIT\r\n\r\n/;' $1
}
if [ "$1" = "-add" ]; then
shift 1
add "$@"
exit $?
fi
ls $HEADERSDIR |xargs -l1 $SHELL "$0" -add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment