Skip to content

Instantly share code, notes, and snippets.

@atomsfat
Created November 1, 2016 21:06
Show Gist options
  • Save atomsfat/c82db0845194283aabf499add58eadd7 to your computer and use it in GitHub Desktop.
Save atomsfat/c82db0845194283aabf499add58eadd7 to your computer and use it in GitHub Desktop.
#!/bin/bash
CURL_FORMAT="URL: %{url_effective} ReturnCode: %{http_code}, TTFB: %{time_starttransfer}, Total time: %{time_total}, Download Size: %{size_download}"
FILE_URL=$1
TOTAL_URL=$(wc -l < $FILE_URL | xargs)
COUNTER=1
echo "1..$TOTAL_URL"
while read LINE
do
RES=$(curl -L -s -o /dev/null -w "$CURL_FORMAT" $LINE)
STATUS=$(echo $RES| grep -o -E 'Code.*?,' | grep -o -E '\d{3}')
if [ "$STATUS" = "200" ] ; then
echo "ok $COUNTER - $RES"
else
echo "not ok $COUNTER - $RES"
fi
COUNTER=$((COUNTER+1))
done < $FILE_URL
@atomsfat
Copy link
Author

atomsfat commented Nov 1, 2016

./url_checker.sh some file

File in contents must be an url by each line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment