How to copy text from the terminal to the clipboard.

To copy text to the clipboard from the Linux command line in Xorg, we need to install a nice utility called xclip. This will allow us to copy text from the terminal to the clipboard.

Install xclip.

[email protected]:~$ sudo apt install xclip

Then create the bash alias we need for this to work.

[email protected]:~$ alias xclip="xclip -selection c"

Now copy some sample text to the clipboard.

[email protected]:~$ echo "Hello Testing." | xclip

That is how easy this is to do. This way it is easy to redirect output of a command or the contents of a text file to the clipboard. Very useful for those of you that use the terminal a lot.

No comments have been made. Use this form to start the conversation :)

Leave a Reply