OS X has a neat command-line tool called pbcopy which takes the standard input and places it in the clipboard to paste into other applications.
In Ubuntu(or any Linux distro with Xwindows), a similar tool is xclip. I like to make this alias:
alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o'
or the following also works if you would rather use xsel:
alias pbcopy='xsel --clipboard --input' alias pbpaste='xsel --clipboard --output'
Now you can pipe any text to pbcopy
$ cat ~/.ssh/id_dsa.pub | pbcopy
Your public ssh key is transferred to your clipboard and is ready to be pasted(perhaps with pbpaste).

September 24th, 2009 at 12:07 am
[...] Jetpack Flight Log ยป pbcopy in Ubuntu (command line clipboard) [...]
May 7th, 2010 at 1:24 pm
Thanks. I know I used something a little more gnome-ish in the past, but just couldn’t remember it.
BTW…. you may need to install xsel or xclip.
$ sudo apt-get install xsel