Skip to content

Instantly share code, notes, and snippets.

@pbyrne
Last active February 25, 2016 20:41
Show Gist options
  • Save pbyrne/bd4e811123be0803f9e7 to your computer and use it in GitHub Desktop.
Save pbyrne/bd4e811123be0803f9e7 to your computer and use it in GitHub Desktop.
A recent gnarly bit of Bash I built up over a few minutes until it did what I needed. I was specifically looking to see which, if any, jobs posted to our job board weren't working, since someone reported that they'd clicked a link and it took them to a broken page, but neglected to tell me which posting it was.
# oneliner
for link in $(curl https://dribbble.com/jobs.rss | grep link | cut -d'>' -f2 | cut -d'<' -f1); do echo $link; curl -I --location $link | grep -E '(Location|HTTP)' | cut -d' ' -f2; echo "--------------------"; done
# expanded
for link in $(curl https://dribbble.com/jobs.rss | grep link | cut -d'>' -f2 | cut -d'<' -f1); # cut the URL out of "<link>http://example.com</link>" from our jobs RSS feed
do echo $link # print it
curl -I --location $link | grep -E '(Location|HTTP)' | cut -d' ' -f2 # get the URL, follow any redirects, and print out each redirect and the ending HTTP status code
echo "--------------------"
done
@jphenow
Copy link

jphenow commented Feb 25, 2016

🔥

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