Skip to content

Instantly share code, notes, and snippets.

@joshuabaker
Created June 30, 2021 15:11
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 joshuabaker/e55e89d6a6200f3b867f36e54fa23754 to your computer and use it in GitHub Desktop.
Save joshuabaker/e55e89d6a6200f3b867f36e54fa23754 to your computer and use it in GitHub Desktop.
Takes a list of URLs and outputs the HTTP status code.
#!/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