Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the xclip command in Linux

Shulou Source: shulou.com Published: 2022-06-01 17:18:49 11月17日 Update

This article mainly introduces how to use the xclip command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

The common Linux command xclip command establishes the channel between the terminal and the clipboard, which can be used to save the terminal output or the contents of the file to the clipboard in the way of the command, or to output the contents of the clipboard to the terminal or file.

Xclip Management X pasteboard

Add that in the X system, there are two mechanisms for copying text from one window to another, namely Selections and cut buffers.

The commonly used copy & paste uses the cut buffers mechanism; in addition, using the mouse to select a paragraph of text, and then pressing the middle mouse button in another window to copy, using the selections mechanism. Selection can be divided into master and slave selection.

When a file is selected with the mouse, the text is automatically copied to master selection. Then press the middle mouse button in another place and paste the contents of the master selection automatically.

Both methods are convenient when you want to copy a small amount of text. But it's troublesome when copying large chunks of text. In addition, you may do some copy-and-paste work frequently, constantly selecting the text with the mouse, and then pasting. This is the torture of the opponent's fingers.

I couldn't stand the torture, so I found xclip, a convenient tool for managing the contents of X selections.

For example, the following command copies the contents of the file / etc/passwd to X master selections.

Xclip-I / etc/passwd can then be copied elsewhere, using the middle mouse button. Or a more comfortable shift+insert. My most common method now is to manage the content of X master selections through keyboard binding. For example, alt+F1 can copy the contents of my ~ / F1 to X master selections,alt+F2 ~ / f2. In this way, you can easily copy and paste the content you need to use frequently. Like a common password or something.

Thank you for reading this article carefully. I hope the article "how to use xclip commands in Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Content command text mouse commonly used file article mechanism terminal cut manage place method time output comfortable frequent between value interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Redmi Huawei Apple MariaDB