Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

linux - 在Bash脚本中管道往返剪贴板(Pipe to/from the clipboard in Bash script)

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

(是否可以在Bash中管道进出剪贴板?)

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

(无论是与设备手柄之间的管道连接还是使用辅助应用程序,我找不到任何东西。)

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

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

cat /dev/clip        # Dump the contents of the clipboard
cat foo > /dev/clip  # Dump the contents of "foo" into the clipboard
  ask by marcog translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

(我希望你可能是一个想要把东西放在X Windows主剪贴板中的Linux用户。)

Usually, the clipboard you want to talk to has a utility that lets you talk to it.

(通常,您要与之交谈的剪贴板具有一个实用程序,可让您与之交谈。)

In the case of X, there's xclip (and others).

(在X的情况下,有xclip (和其他)。)

xclip -selection c will send data to the clipboard that works with Ctrl + C , Ctrl + V in most applications.

(xclip -selection c将数据发送到剪贴板,在大多数应用程序中使用Ctrl + CCtrl + V。)

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

(如果你使用的是Mac OS X,那就是pbcopy 。)

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

(如果您处于Linux终端模式(没有X),那么请查看具有剪贴板的gpm屏幕 。)

Try the screen command readreg .

(尝试使用screen命令readreg 。)

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

(在Windows 10+或cygwin下,使用/dev/clipboardclip 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...