views:

1310

answers:

4

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?

+2  A: 

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.

ddvlad
Thank you for mentioning xsel. It raised me another problem: how to configure Mackbook touchpad to understand the mouse wheel button. I need get the xmod code first for the button.
Masi
+6  A: 

The Linux equivalent of pbcopy is xclip.

Can Berk Güder
+5  A: 

does xclip suits you?

Konstantinos
+5  A: 

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?).

hlovdal
This is an excellent link for the tips about the commands: http://www.cyberciti.biz/faq/xclip-linux-insert-files-command-output-intoclipboard/
Masi