Last active
June 15, 2023 17:58
-
-
Save nalmeida/1c102496cf46679bed839c7aa677c260 to your computer and use it in GitHub Desktop.
Test HTTP Status Code using cURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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