I would like to copy the contents of a file to the X11 CLIPBOARD target text/html using the command line.

Ideally, this would be as portable as possible across different flavors of Linux and possibly other Unices.

1 Answer 1


I don't know the legacy UNIX flavors but under redhat and debian compatible linux distros, there exist a binary called xclip, which does exactly what you want.

If you don't have it on your system, you can install it

Redhat variants

yum install xclip 

Debian based

apt-get install xclip
  • As far as I know, only xclip versions built from SVN support setting the target. The versions shipped by default in Arch and Debian, at least, are not bleeding edge enough.
    – PythonNut
    Commented Jan 6, 2016 at 22:19
  • @PythonNut xclip in Debian jessie (current stable, version 0.12+svn84) does support xclip -t $target. Commented Jan 6, 2016 at 23:40
  • @Gilles you're right. However, I just tested it in Arch, and it doesn't work. :(
    – PythonNut
    Commented Jan 7, 2016 at 5:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .