js复制文本到剪贴板_如何将输出文本从命令行复制到Windows剪贴板

js复制文本到剪贴板

js复制文本到剪贴板

If you’re doing work at the command line on your Windows box, it’s sometimes useful to copy the output of a command to the clipboard, but who wants to try and scroll and click to use copy and paste? Here’s how to do it the easy way.

如果要在Windows框上的命令行中进行工作,将命令的输出复制到剪贴板有时会很有用,但是谁想尝试滚动并单击以使用复制粘贴 ? 这是简单的方法。

Note: For the purposes of our exercise, we’ll be using the built-in clip utility in Windows 7 or Vista—if you are using Windows XP, you can download clip.exe from Microsoft, just make sure to save the file in the Windows directory.

注意:为了便于练习,我们将在Windows 7或Vista中使用内置的clip实用程序-如果您使用的是Windows XP,则可以从Microsoft下载clip.exe ,只需确保将文件保存在Windows目录。

将输出从命令行应用程序复制到剪贴板 (Copy Output from Command Line Applications to the Clipboard)

To copy text from a command to the clipboard, we’ll just pipe it into the clip command, like this:

要将文本从命令复制到剪贴板,我们只需将其通过管道传递到clip命令,如下所示:

<command> | clip

<命令> | 夹

For example, if you wanted to output from the echo command into the clipboard, you could do this:

例如,如果要从echo命令输出到剪贴板,可以执行以下操作:

image

You can also use redirection to send a text file directly into the clip utility, like this:

您还可以使用重定向将文本文件直接发送到clip实用程序,如下所示:

clip < filename.txt

剪辑<filename.txt

In this example I’m gonna put the contents of the single.php file onto the clipboard:

在这个例子中,我将把single.php文件的内容放到剪贴板上:

image

Of course, you could also use the type command and then pipe it to the clipboard like so:

当然,您也可以使用type命令,然后将其通过管道传输到剪贴板,如下所示:

image

Regardless of the one you use, you’ll then be able to paste the content into any other application that you’d like:

无论使用哪种软件,都可以将内容粘贴到您想要的任何其他应用程序中:

image

创建上下文菜单助手以将文件内容复制到剪贴板 (Create a Context Menu Helper to Copy File Contents to the Clipboard)

image

You can take the clip utility a step further by adding a context menu item that lets you copy the contents of any file directly to the clipboard. All you’ll need to do is follow the instructions in the following article, or download the reghack file.

通过添加上下文菜单项,可以使clip实用程序更进一步,使您可以将任何文件的内容直接复制到剪贴板。 您所需要做的就是按照下一篇文章中的说明进行操作,或者下载reghack文件。

Create a Context Menu Item to Copy a Text File To the Clipboard in Windows 7 / Vista / XP

创建上下文菜单项以将文本文件复制到Windows 7 / Vista / XP中的剪贴板

And of course, don’t forget that you can always copy the path of the file to the clipboard through the context menu.

当然,不要忘记,您始终可以通过上下文菜单将文件的路径复制到剪贴板

翻译自: https://www.howtogeek.com/howto/28473/how-to-copy-output-text-from-the-command-line-to-the-windows-clipboard/

js复制文本到剪贴板

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值