-
-
Save realdubb/227504678024a79c759d886c7464cd0f to your computer and use it in GitHub Desktop.
Script to test for 404s
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/sh | |
# 404-check.sh - Script to test for 404s | |
# author: lkptrzk | |
# Usage: | |
# Assuming a file named 'input' with one URL per line | |
# the following command will output which files were 404s: | |
# cat input | xargs 404-check.sh | |
# Notes: | |
# curl -I = only get headers | |
# 2>/dev/null = prevent stderr from going through the pipe | |
# (causes problems when piping curl) | |
# head -1 = HTTP response code should be first line of output from curl | |
for arg in $@ ; do | |
currUrl=$arg | |
curl -I 2>/dev/null $currUrl | head -1 | grep 404 >/dev/null | |
if [ $? == 0 ] ; then | |
echo $currUrl | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment