linux命令行剪贴板

xclip is a tool to copy the copy the output of commands from a command line in a terminal to X selection or clipboard. It connects the command line interface and the X selections (clipboard) and is a very useful tool. For example, processing some text in vim in a terminal and then copying it to the browser will be easily handled by xclip.

xclip是一个工具,可将命令的输出从终端中的命令行复制到X选择或剪贴板。 它连接命令行界面和X选择(剪贴板),是一个非常有用的工具。 例如,在终端中在vim中处理一些文本,然后将其复制到浏览器将很容易被xclip处理。

There are lots good documents and tutorials on the Web including xclip man page, this tutorial and this one. I just give two very common use cases with the command examples. Make sure you have already installed it. On Fedora Linux, you can install it by # yum install xclip.

Web上有很多不错的文档和教程,包括xclip手册页本教程 教程 。 我仅通过命令示例给出两个非常常见的用例。 确保您已经安装了它。 在Fedora Linux上 ,可以通过# yum install xclip

将文件(file.txt)的内容复制到其他X应用程序中 (Copying a file (file.txt)’s content to the other X applications )

2 methods here.

这里有2种方法。

方法1.使用X选择 (Method 1. Use X selection )

First, copying the file content by

首先,通过

$ cat file.txt | xclip

Beside of using cat, you can also use xclip’s -i option.

除了使用cat ,您还可以使用xclip的-i选项。

Then, go the the X application’s input box and hit the middle key or scroll wheel.

然后,转到X应用程序的输入框,然后按中键或滚轮

方法2.使用X剪贴板 (Method 2. Use X clipboard )

First, copying the file content by

首先,通过

$ cat file.txt | xclip -selection c

Then, go the the X application’s input box and press Ctrl + V.

然后,转到X应用程序的输入框, 然后按Ctrl + V。

将剪贴板内容复制到文件(out.txt) (Copying the clipboard content to a file (out.txt) )

First, copying the file content in the X application by Ctrl + C as usually or by selecting them (using your mouse) as usual.

首先,通常按Ctrl + C或通常选择 (使用鼠标选择它们 ,从而在X应用程序中复制文件内容。

Then, saving the content you copied to a file.

然后,将您复制的内容保存到文件中。

$ xclip -o >out.txt

This step is the same no matter you use Ctrl + C or **selection in the previous step.

无论您在上一步中使用Ctrl + C还是**选择,此步骤都是相同的。

For more options, check the xclip man page.

有关更多选项,请检查xclip手册页

翻译自: https://www.systutorials.com/copying-output-of-commands-in-linux-terminals-to-x-selection-clipboard/

linux命令行剪贴板

Logo

更多推荐