If you sent a curl request to the slashdot.org server you get back a random Futurama quote contained within the header information. The following curl command:
curl -Is slashdot.org
The commands supplied are I and s. I causes only the header of the file to be shown and s stops curl printing out anything. This returns the following headers:
- HTTP/1.1 200 OK
- Date: Wed, 25 Jun 2008 08:34:43 GMT
- Server: Apache/1.3.41 (Unix) mod_perl/1.31-rc4
- SLASH_LOG_DATA: shtml
- X-Powered-By: Slash 2.005001
- X-Bender: I'm an outdated piece of junk.
- Cache-Control: private
- Pragma: private
- Connection: close
- Content-Type: text/html; charset=iso-8859-1
Which contains a quote from Bender. To grab the correct line we then pass this through a regular expression to find a line that starts with an "X" and a dash, followed be either a B (for Bender) or an F (for Fry). The following line:
curl -Is slashdot.org | egrep '^X-(F|B)'
Will print off the line from the above header information.
X-Bender: I'm an outdated piece of junk.
We can then cut apart the string to extract everything after the "X-". This is done with the cut command.
curl -Is slashdot.org | egrep '^X-(F|B)' | cut -d \- -f 2
I this case the cut command splits the string by the dash and then returns the second part of it, which contains the quote we need. The final outputted line is as follows:
Bender: I'm an outdated piece of junk.
Try this for yourself!