Unable to copy fast a file to clipboard in a Linux

2019-03-20 02:52发布

I have not yet found an easy solution to copy your file to a clipboard in Linux, similarly as in Mac by

cat file | pbcopy

I tried to use the following command in Vim unsuccessfully

:copy 1,9999999

to copy the file.

How can you copy a file fast to your clipboard in Linux such that you can then paste it to dpaste?

4条回答
Root(大扎)
2楼-- · 2019-03-20 03:04

Try xsel. It does wonders, but it doesn't really work with the clipboard, but rather with the X selection buffer.

cat file | xsel

and then you can click the mouse wheel to paste the contents.

查看更多
Anthone
3楼-- · 2019-03-20 03:06

The Linux equivalent of pbcopy is xclip.

查看更多
对你真心纯属浪费
4楼-- · 2019-03-20 03:07

does xclip suits you?

查看更多
在下西门庆
5楼-- · 2019-03-20 03:10

In addition to xsel and xclip already mentioned there is also uclip. From the manual page description:

uclip is a command-line interface to the X clipboard. It either copies text, from FILE or from stdin, to the X clipboard, or prints the X clipboard to std- out. uclip supports Unicode and is locale-aware (in contrast to other similar utilities). uclip was written using Qt.

Update: Apparently uclip was not such a good recommendation because it currently does not work for copying, see here for the problem description (and hopefully a solution some day?).

查看更多
登录 后发表回答