Michael Jay Lissner
  • Home
  • About Site
  • Contact
  • Projects & Papers
  • Tags
  • Archives

Linux Tip - Route Standard Output Into to the Clipboard

A friendly online stranger just taught me how to do something that has been plaguing me for some time. Ever since I learned how to use pipes in the unix commandline, I have wanted to know how to pipe the output of a command into the system clipboard.

For example, the echo command simply repeats whatever you tell it to. So if I run

echo hello

The computer will give me the output

hello

By using a pipe (this symbol: |) I can route the output of one command into the input of another.

For example, if I run:

echo hello | helloprogram

The helloprogram will receive the value of ‘hello’ as an input, and will do something with it. This allows stringing together small commands into long ones, which sometimes is incredibly handy.

Anyway, if you want to route standard output into the system clipboard, you will need to install an application called xclip. Once that is installed, a command such as:

echo hello | xclip -i -selection clipboard

Will put the word hello into the clipboard. Ctrl + V will then paste that value into whatever application desired.

Thanks to aaron at http://www.cyberciti.biz/faq/linux-copying-with-middle-mouse-button/#comment-38676 for help with this question.

I love getting feedback and comments. Make my day by making a comment.

Comments
comments powered by Disqus

  • « Ch-ch-ch-ch-Changes
  • Sarah Palin - Worst candidate of all time? »

Published

Aug 28, 2008

Category

Tech

Tags

  • CLI 1
  • Linux 14

Contact

This is Reader-Editable

Edit this post on Github

Get Weekly Updates

  • Unless mentioned otherwise, all material on this site is licensed under a Creative Commons copyright or the GNU Affero GPL. Privacy Policy.
  • Powered by Pelican. Theme: Elegant by Talha Mansoor