Linux 输出重定向到剪贴板

xsel

安装xsel

1
sudo apt-get install xsel

输出到剪贴板中

1
cat file | xsel -i -b
1
echo HelloWorld | xsel -i -b

读取剪贴板内容

1
xsel -o -b

运行效果:

1
2
3
4
5
6
7
blue@blue-VirtualBox:~$ echo HelloWorld | xsel -i -b
blue@blue-VirtualBox:~$ xsel -o -b
HelloWorld
blue@blue-VirtualBox:~$ echo HelloWorld! | xsel -i -b
blue@blue-VirtualBox:~$ xsel -o -b
HelloWorld!
blue@blue-VirtualBox:~$

参考资料

https://blog.csdn.net/aka_xingwenpeng/article/details/8776779
https://blog.csdn.net/mosesmo1989/article/details/51094957