Skip to content

Instantly share code, notes, and snippets.

@igilham
Last active February 22, 2024 15:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igilham/12eb33ab8a86f1e815d2 to your computer and use it in GitHub Desktop.
Save igilham/12eb33ab8a86f1e815d2 to your computer and use it in GitHub Desktop.
Test if a list of files (URLS) exist on a web server
#!/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