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'
If you do not have xclip pre installed you can install it running following command in terminal before making the alias
# For Ubuntu or Debian users sudo apt-get install xclip -y # For Fedora/CentOS users sudo yum install xclip -y