在Bash脚本中管道往返剪贴板 [英] Pipe to/from the clipboard in Bash script

查看:107
本文介绍了在Bash脚本中管道往返剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过Bash在剪贴板中进行管道传输?

Is it possible to pipe to/from the clipboard in Bash?

无论是与设备句柄之间的管道传输还是使用辅助应用程序,我都找不到任何东西.

Whether it is piping to/from a device handle or using an auxiliary application, I can't find anything.

例如,如果/dev/clip是链接到剪贴板的设备,则我们可以这样做:

For example, if /dev/clip was a device linking to the clipboard we could do:

cat /dev/clip        # Dump the contents of the clipboard
cat foo > /dev/clip  # Dump the contents of "foo" into the clipboard

推荐答案

您可能要处理很多剪贴板.我希望您可能是Linux用户,希望将内容放入X Windows主剪贴板.通常,您要与之交谈的剪贴板都有一个实用程序,可让您与其交谈.

There's a wealth of clipboards you could be dealing with. I expect you're probably a Linux user who wants to put stuff in the X Windows primary clipboard. Usually, the clipboard you want to talk to has a utility that lets you talk to it.

对于X,为xclip(及其他).在大多数应用程序中,xclip -selection c会将数据发送到使用 Ctrl + C Ctrl + V 的剪贴板.

In the case of X, there's xclip (and others). xclip -selection c will send data to the clipboard that works with Ctrl + C, Ctrl + V in most applications.

如果您使用的是Mac OS X,则有pbcopy.

If you're on Mac OS X, there's pbcopy.

如果您处于Linux终端模式(无X),请查看gpm屏幕,其中有一个剪贴板.尝试screen命令readreg.

If you're in Linux terminal mode (no X) then look into gpm or screen which has a clipboard. Try the screen command readreg.

在Windows 10+或cygwin下,使用/dev/clipboardclip.

Under Windows 10+ or cygwin, use /dev/clipboard or clip.

这篇关于在Bash脚本中管道往返剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆