xclip is a command line program which interacts with X11 clipboard.

To install it :

root@localhost:~# apt-get install xclip

To use, have a look at the example below :

fool@localhost:~$ ls |xclip

I have just listed the content of my current working directory and then put it to X11 clipboard through the “|” command.

To insert this content to a program like a GUI text editor, I have to paste by clicking on the middle button of my mouse.

xclip can receive the content of a whole fileĀ  :

fool@localhost:~$ xclip /etc/fstab

To display the content of xclip :

fool@localhost:~$ xclip -o