Posted: . At: 8:33 PM. This was 8 years ago. Post ID: 9362
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

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.

jason@jason-desktop:~$ sudo apt install xclip

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

jason@jason-desktop:~$ alias xclip="xclip -selection c"

Now copy some sample text to the clipboard.

jason@jason-desktop:~$ 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.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.