Created
June 30, 2021 15:11
-
-
Save joshuabaker/e55e89d6a6200f3b867f36e54fa23754 to your computer and use it in GitHub Desktop.
Takes a list of URLs and outputs the HTTP status code.
This file contains hidden or 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/sh | |
# Usage | |
# | |
# chmod 755 http-status-codes.sh | |
# | |
# cat list-of-urls.txt | xargs http-status-codes.sh | |
for arg in $@ ; do | |
statusCode=`curl -I 2>/dev/null $arg | head -n 1 | awk '{print $2}'` | |
if [ "$statusCode" = "200" ]; then | |
printf "\e[92m$statusCode\e[0m $arg\n" | |
else | |
printf "\e[91m$statusCode\e[0m $arg\n" | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment