Last active
February 22, 2024 15:54
-
-
Save igilham/12eb33ab8a86f1e815d2 to your computer and use it in GitHub Desktop.
Test if a list of files (URLS) exist on a web server
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 | |
# List missing files from a web server. Missing means we get a non-200 response. | |
BASE="http://www.example.com" | |
FILES="index.html | |
about.html" | |
for ITEM in ${FILES}; do | |
URL="${BASE}/${ITEM}" | |
# --head may work in some environments | |
curl -s -D - "${URL}" -o /dev/null | head -1 | grep 'HTTP/1.[01] 200' > /dev/null | |
if [ $? == 1 ]; then | |
echo "${ITEM} not found" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment