CLI to evaluate the HTTP Code for a list of URLs
#!/bin/bash | |
while IFS= read -r LINE || [ "$LINE" ]; do | |
# https://curl.haxx.se/docs/manpage.html | |
IN=$(curl -o /dev/null --silent --head --write-out "%{http_code};%{redirect_url}" "$LINE") | |
# https://stackoverflow.com/a/5257398 | |
arrIN=(${IN//;/ }) | |
if [ "${arrIN[0]}" = "301" ] || [ "${arrIN[0]}" = "302" ]; then | |
printf "${arrIN[0]},$LINE,${arrIN[1]}\n" | |
else | |
printf "${arrIN[0]},$LINE\n" | |
fi | |
done < "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Usage:
./httpcode url-list.txt