Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have a bash script put some text in the system clipboard?

(I use Ubuntu with default Gnome and Bash.)

share|improve this question
up vote 5 down vote accepted

There is a commandline tool xclip .
Example: Copy output of the following command to clipboard:

$ sort -n -k 3, -k 2 file.txt | xclip


share|improve this answer
Accepted, for I could install it via my package manager. Thank you. – DerMike Dec 21 '11 at 14:20

I haven't tried it on my own, but there is a Bash Clipboard Interactive Script project on SourceForge:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.