I was inspired by another question to write a script (or rather a one-liner) to grab random Wikipedia pages.
Here's what I've got so far:
# Grab the HTTP header response from Wikipedia's random page link
curl 'http://en.wikipedia.org/wiki/Special:Random' -sI
# Search STDIN for the Location header and grab its content
perl -wnl -e '/Location: (.*)/ and print $1;'
And this works. It outputs a random Wikipedia URL to the console. But I need to append "?printable=yes" to that url to get the Wikipedia page without all the non-article content.
However, running:
curl 'http://en.wikipedia.org/wiki/Special:Random' -sI | perl -wnl -e '/Location: (.*)/ and print $1 . "?printable=yes";'
Outputs: ?printable=yespedia.org/wiki/James_Keene_(footballer)
Why is my concatenation not concatenating?
UPDATE:
For the curious, here is the one-liner in its completion:
curl `curl 'http://en.wikipedia.org/wiki/Special:Random' -sI | perl -wnl -e '/Location: ([^\r]*)/ and print $1 . "?printable=yes";'`