Skip to content

Instantly share code, notes, and snippets.

@m-rey
Last active November 13, 2020 17:07
Show Gist options
  • Save m-rey/1517fcd261859e0a3f4cb45d5171fe56 to your computer and use it in GitHub Desktop.
Save m-rey/1517fcd261859e0a3f4cb45d5171fe56 to your computer and use it in GitHub Desktop.
script to check if list of urls is reachable (2xx HTTP response)
#!/bin/bash
while read line; do url_return=($(curl -s -o /dev/null -IL -m 10 -w "%{http_code} %{url_effective}" "$line")); if [ ${url_return[1]} -ge 200 ] && [ ${url_return[1]} -lt 300 ] ; then echo "${url_return[@]:1}">>"url_reachable.txt"; else echo "${url_return[@]:1}">>"url_failed.txt"; fi; done<url.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment