Found a neat trick the other day via github.com, in their instructions for copying public keys. pbcopy (pasteboard copy) on mac OSX is a command that puts it's input into the clipboard so you can paste the output anywhere.
In this example the output of
ls -la is now available to be pasted from your clipboard:
muffin@shiva $ls -la | pbcopy
Rather awesomely the reverse is also available it's called pbpaste. If you copy something to your clipboard you can then make use of it in the terminal with the pbpaste command. In other words pbpaste just sends the contents of your clipboard to stdout.
This example for the mac writes out the clipboard to the file, index.html:
xclip and one called xsel, that replicate pbpaste and pbcopy. Additionally if you use Cygwin you can make use of getclip and putclip.
muffin@shiva $pbpaste > index.html