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.
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 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. xclip -t $target.