In X windows system, clipboard is a mechanism for transferring data from one window to another, or sharing data among different applications. Typically you use a mouse to select a text and copy it to clipboard.
However, if you want to copy the whole file content to clipboard without opening it, you can use xclip, which is a command line interface to clipboard. The xclip command can read text directly from standard input, and copy it to clipboard.
Install xclip on Linux
To install xclip on Ubuntu, Debian or Linux Mint:
To install xclip on Fedora or RHEL:
To install xclip on CentOS, first enable Repoforge repository, and then run:
Copy File Content to Clipboard using Xclip
To copy the content of a file to clipboard, simply run the following command.
Once the file content is copied to clipboard, you can paste it into another window or application simply by clicking on mouse middle-button.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!