xclip is command line interface to X selections/clipboard that is designed to run on any system with any X11 implementation, with xclip, we can not easily manipulate the data on the clipboard under a terminal in X11, no need to open a file for just copy its content anymore, and no need to move the mouse to select the output and copy it anymore. Except xclip, there is also a similar program called xsel, google it if you are interested in.
The homepage of xclip:
- New one on GitHub: https://github.com/astrand/xclip
- Old one on SourceForge: http://xclip.sourceforge.net
$ sudo apt-get install xclip # on Debian / Ubuntu based GNU/Linux distros
$ sudo pkg install xclip # on FreeBSD
So how to use it?
If you want to copy something to clipboard, just pipe to xclip like this:
$ echo "Hello xclip" | xclip -selection clipboard
Now you can paste it as usual.
If you want to show something from clipboard, just call xclip to output:
$ xclip -selection clipboard -o
xclip will output to standard output (stdout), so you can pipe or redirect the result to other utility and do some works you want.