Skip to content

Instantly share code, notes, and snippets.

@jadedgnome
Forked from hrwgc/validate.sh
Last active August 29, 2015 14:13
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 jadedgnome/458d3deb91d20561298b to your computer and use it in GitHub Desktop.
Save jadedgnome/458d3deb91d20561298b to your computer and use it in GitHub Desktop.
#!/bin/bash
# simple function to check http response code before downloading a remote file
# example usage:
# if `validate_url $url >/dev/null`; then dosomething; else echo "does not exist"; fi
function validate_url(){
if [[ `wget -S --spider $1 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then echo "true"; fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment