Skip to content

Instantly share code, notes, and snippets.

@vtmx
Created July 5, 2026 13:53
Show Gist options
  • Select an option

  • Save vtmx/a4992c608efcb18775c4335ee2561bb8 to your computer and use it in GitHub Desktop.

Select an option

Save vtmx/a4992c608efcb18775c4335ee2561bb8 to your computer and use it in GitHub Desktop.
checksite
#!/usr/bin/env bash
if [[ ! "$1" ]]; then
echo 'error: need file'
exit 1
fi
file="$1"
parallel=10
check_url() {
local url="$1"
local timeout=3
local curl_opts=(\
-s \
-o /dev/null \
-w "%{http_code}" \
--max-time $timeout \
--connect-timeout $timeout \
-A "Mozilla/5.0" \
)
if curl "${curl_opts[@]}" "$url" | grep -q 200; then
printf "\033[32mON - %s\033[0m\n" "$url"
else
printf "\033[31mOF - %s\033[0m\n" "$url"
fi
}
export -f check_url
sed -En 's/.*HREF="([^"]*)".*/\1/p' "$file" | xargs -I {} -P $parallel bash -c 'check_url "$1"' _ {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment