Skip to content

Instantly share code, notes, and snippets.

@freddiemixell
Created August 27, 2019 16:22
Show Gist options
  • Save freddiemixell/61a4ac0360edf7a8816b3cf05dd1d154 to your computer and use it in GitHub Desktop.
Save freddiemixell/61a4ac0360edf7a8816b3cf05dd1d154 to your computer and use it in GitHub Desktop.
Check Redirects By CSV Output Pass/Fail
check_redirects() {
while IFS=, read -r req dest;
do
test="$req => $dest"
echo "Now testing $test"
if curl -Is "$1"$req | grep -s $dest; then
result=Pass
else
result=Fail
fi
echo "$result: $test" >> results.log
sleep 1
done < "$2"
}
@freddiemixell
Copy link
Author

Add this to your ~/.bashrc or in my case ~/.zshrc for checking a csv of redirects for any particular site.

Run: check_redirects https://example.com /path/to/redirects.csv

@freddiemixell
Copy link
Author

freddiemixell commented Aug 27, 2019

I don't have anything in place to fail if you don't pass the 2 params. Also, I don't have time to put those in place but if anyone wants to comment with error handling I'll update the Gist! 😄

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