它是可能的管道到/从剪贴板在Bash?

无论是连接到设备手柄还是使用辅助应用程序,我都找不到任何东西。

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

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

当前回答

复制和粘贴到剪贴板在Windows (Cygwin):

See:

$ clip.exe -?

CLIP
Description:
    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.
Parameter List:
/?                  Displays this help message.
Examples:
DIR | CLIP          Places a copy of the current directory
                        listing into the Windows clipboard.
CLIP < README.TXT   Places a copy of the text from readme.txt
                        on to the Windows clipboard.

还有getclip(它可以代替Shift + Ins!)和putclip (echo oeuoa | putclip.exe将其放入clip)存在。

其他回答

Try

xclip

xclip - command line interface to X selections (clipboard) 

man

如果您像我一样在没有根权限的Linux服务器上运行,并且没有任何xclip或GPM,您可以通过使用临时文件来解决这个问题。例如:

$ echo "Hello, World!" > ~/clip
$ echo `cat ~/clip`
Hello, World!

几年前我写的几个Windows程序。它们允许您转储,推送,追加和打印剪贴板。它是这样工作的:

dumpclip | perl -pe "s/monkey/chimp/g;" | pushclip

它包括源代码:cmd_clip.zip

在macOS系统中,请使用pbpaste。

例如:

更新剪贴板

pbpaste  | ruby -ne ' puts "\|" + $_.split( )[1..4].join("\|") ' | pbcopy

在macOS系统下,请使用内置的pbcopy和pbpaste命令。

例如,如果你跑步

cat ~/.bashrc | pbcopy

~/的内容。可以使用Cmd + V快捷方式粘贴bashrc文件。

要保存当前剪贴板到一个文件,将输出pbpaste重定向到一个文件:

pbpaste > my_clipboard.txt