Skip to content

Instantly share code, notes, and snippets.

@ETetzlaff
Forked from hrwgc/validate.sh
Created April 11, 2016 18:46
Show Gist options
  • Select an option

  • Save ETetzlaff/c6e813c8ebb5a9735c9a56caa77cde8a to your computer and use it in GitHub Desktop.

Select an option

Save ETetzlaff/c6e813c8ebb5a9735c9a56caa77cde8a to your computer and use it in GitHub Desktop.

Revisions

  1. @hrwgc hrwgc created this gist Nov 13, 2013.
    10 changes: 10 additions & 0 deletions validate.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/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
    }