Ubuntu: How to write to data to copy and paste buffer? [duplicate]



Question:

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?


Solution:1

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.


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »