This question already has an answer here:

How do i write data from the Command-line into the copy paste buffer? I see the programs xsel, and xclip and they look fine, but i would prefer a command line option. Can i redirect terminal output to the buffer some how? What is the technical name for the copy paste buffer?

I use mate for the desktop environment. The reason I want to be able to do this without installing anything is I want to be able to write scripts to use this function even on systems where i am not an administrator... i know i can compile in my home directory, but i would still prefer a standard output method. I wouldnt mind writing a bit of c-code to do it either.

I am still not certain, perhaps the copy paste buffers are just frame buffers?

marked as duplicate by Radu Rădeanu, karel, Eric Carvalho, Warren Hill, qbi Nov 6 '13 at 19:19


  • I guess it depends on the virtual terminal application you're running. Do you run gnome-terminal, xterm or something else? Do you use X or is it just the linux console? – user85164 Nov 5 '13 at 3:20

To redirect STDOUT to the X11 clipboard, you can pipe it into xclip:

$  echo -n my example text to STDOUT | xclip -i -selection clipboard

You can see what's in the clipboard with:

$  xclip -o -selection clipboard

See xclip man page for more details.


The simplest way (if I understand correctly what you want) is to select the text with your mouse and then use CTRLSHIFTC to copy it into the regular clipboard. From there you use the standard CTRLV to paste it into any application in your GUI.

To paste copied text from the GUI into the terminal you use CTRLSHIFTV.
