关于linux:WindowsMacLinux-如何将内容输出到剪贴板

如何将输入间接复制至剪切板?在不同的零碎中,所应用的命令是不同的。

Mac

// 将输入复制至剪贴板
$ echo "hello mac" | pbcopy

// 将文件中的内容全副复制至剪贴板
$ pbcopy < remade.md

// 将剪切板中的内容粘贴至文件
$ pbpaste > remade.md

Linux

Linux 用户须要先装置 xclip,它建设了终端和剪切板之间的通道。

// 查看剪切板中的内容
$ xclip -o
$ xclip -selection c -o

// 将输入复制至剪贴板
$ echo "hello xclip" | xclip-selection c

// 将文件中的内容全副复制至剪贴板
$ xclip -selection c remade.md

// 将剪切板中的内容粘贴至文件
$ xclip -selection c -o > remade.md

或者间接应用xsel命令:

// 将输入复制至剪贴板
$ echo "hello linux" | xsel

// 将文件中的内容全副复制至剪贴板
$ xsel < remade.md

须要留神的是:xsel、xclip 命令是在 X 环境下应用的,所以近程连贯服务器时应用会报异样:

xclip error can't open display (null)

Windows

// 将输入复制至剪贴板
$ echo "hello windows" | clip

// 将文件中的内容全副复制至剪贴板
$ clip < remade.txt

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理