A clipboard is non-permanent storage on your computer for data that the user wants to copy from one path to another. Later, you can also paste that data stored in the clipboard to somewhere else as well. Until logging off of the system or cutting/copying something, the data on the clipboard is saved. This might be a word selection, a picture, a file, or any other form of data.

You can also clip text from one section of a document and paste it into another portion of the document or somewhere else in a word processing program. The selected information will be copied and kept in the clipboard till you paste it somewhere. Xclip is a great tool that is used as a clipboard in Ubuntu OS. This article is focussing on how you can install and use Xclip clipboard. Let’s begin:

How to install Xclip in Ubuntu

You can get the Xclip by typing the below-given command in the terminal:

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-18.png" data-lazy- height="669" src="data:image/svg xml,” width=”972″>

You can check its feature using the command in the terminal:

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-19.png" data-lazy- height="673" src="data:image/svg xml,” width=”971″>

You can also get additional help on how to use the xclip clipboard using the below-mentioned command in the terminal:

This command will open up a new window in the terminal where you can find all the functionality of the xclip clipboard. If you are unsure and don’t know how to use this clipboard, you can also take some help from the examples mentioned there by scrolling down a little that can be seen in the image below.

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-20.png" data-lazy- height="481" src="data:image/svg xml,” width=”735″>

How to use Xclip clipboard in Ubuntu with examples

Let’s take some of the examples of this clipboard for better understanding. Suppose you want to copy the name of any website to the clipboard, and then later, you can also paste it by the following method mentioned below.

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-21.png" data-lazy- height="582" src="data:image/svg xml,” width=”766″>

$ echo “www.Linuxhint.com”|xclip

The above command is used to copy the website name, “www.Linuxhint.com” in this case, to the xclip clipboard. The second command is mentioned below:

It is used to paste the content present in the clipboard displayed on the third line of the terminal.

Suppose you want to display the date and time using the clipboard, execute the command mentioned below:

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-22.png" data-lazy- height="578" src="data:image/svg xml,” width=”769″>

How to copy the content of a text file using the xclip clipboard in Ubuntu OS

Now let’s take another example of copying the content of any text file and then paste it onto the terminal. For this approach, create the text file first which you can do by using any text editor. In our case, we are using the “VIM” text editor. You first need to install it if you hav’nt then use the command mentioned below:

After its installation, the next step is to create a text file with some content inside it. Use the below-mentioned to create a file:

This will open a vim editor with a file name of “testfile.txt” to write anything that can be seen below.

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-23.png" data-lazy- height="482" src="data:image/svg xml,” width=”736″>

Here “:wq” is used to save and quit the vim editor. Now, as the file is saved, the next step is to move the content of the text file to the clipboard and then later paste the content as well. Use the command as shown below:

<img alt="Text Description automatically generated" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/text-description-automatically-generated-24.png" data-lazy- height="579" src="data:image/svg xml,” width=”817″>

The first command will copy the content to the clipboard. Later you can also access the file’s content from the clipboard that has already been discussed before. You can also press the mouse’s middle button to paste the clipboard’s content instead of typing the command $xclip -o, but sometimes we don’t have the mouse as we are working with a laptop mousepad or using the mouse having two buttons only. So, it is not always recommended.

Conclusion

A clipboard is a great tool where the copied data or information from any text file, a picture can be stored, and later that information can be retrieved when needed. It allows you to transfer text and files throughout your system with ease. A lot more can be done to make it easier to use and add new features. All of this can be done using the Xclip clipboard. All you need to do is install it and later understand its functionality by thoroughly reading this article.