Follow Redirects with cURL
I love playing around with cURL. There's something about loading websites via command line that makes me feel like some type of smug hacker, just like tweeting from command line does.
I recently cURL'd the Google homepage and saw the following:
curl google.com #<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> #<TITLE>301 Moved</TITLE></HEAD><BODY> #<H1>301 Moved</H1> #The document has moved #<A HREF="http://www.google.com/">here</A>. #</BODY></HTML>
I found it weird that Google does the initial redirect but I still want to get the source of the Google homepage with cURL, as with any site that may do a redirect without you noticing. Luckily it's just a single flag:
curl -L google.com #<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en">...
-L flag instructs cURL to follow any redirect so that you reach the eventual endpoint. Those tiny redirects are just noise anyways, right?