Windows/Mac/Linux 如何将内容输出到剪贴板
文章目录
如何将输出直接复制至剪切板?在不同的系统中,所使用的命令是不同的。
Mac
// 将输出复制至剪贴板
$ echo "hello mac" | pbcopy
// 将文件中的内容全部复制至剪贴板
$ pbcopy < remade.md
// 将剪切板中的内容粘贴至文件
$ pbpaste > remade.mdLinux
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
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论