Skip to content

Instantly share code, notes, and snippets.

@nalmeida
Last active June 15, 2023 17:58
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 nalmeida/1c102496cf46679bed839c7aa677c260 to your computer and use it in GitHub Desktop.
Save nalmeida/1c102496cf46679bed839c7aa677c260 to your computer and use it in GitHub Desktop.
Test HTTP Status Code using cURL
#!/bin/bash
# status.sh
# source: https://stackoverflow.com/questions/6136022/script-to-get-the-http-status-code-of-a-list-of-urls
while read LINE; do
curl -o /dev/null --silent --head --write-out "%{http_code} $LINE\n" "$LINE"
done < url-list.txt
# Maycon suggestion
#!/bin/bash
urls=(
"https://blog.gympass.com/en/35-lgbtq-supportive-gyms-across-the-us/"
"https://blog.gympass.com/en/5-fantastic-reasons-to-get-fit-now/"
"https://blog.gympass.com/en/top-excuses-for-not-exercising-and-how-to-overcome-them/"
)
for url in "${urls[@]}"
do
echo "URL: $url"
status_code=$(curl -s -o /dev/null -w "%{http_code}" "$url")
echo "Status code: $status_code"
done
echo "Finished."
https://news.gympass.com/lifestyle/
https://news.gympass.com/lifestyle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment