I'm wondering if there is a command line clipboard manipulation program for Linux like xsel or xclip that supports RTF formatted data? What I mean is, if I use xsel to put RTF data on the clipboard, when I paste I get ASCII RTF code—not formatted text. Xsel and xclip can only handle plain text.

On MacOS, the pbpaste and pbcopy commands will automatically set the content type of the clipboard to RTF if there is an RTF header in the data. I'm looking for a Linux program that will do just that.

I need to use it in scripts, so graphical clipboard managers will not work.


Correct me if I'm wrong, but I think that the application that you are pasting to support formatting. I have done some copy/paste handling in my day, and I had to format whatever data I get from the paste command.

As for the headers, what environment are you running, Gnome or KDE? AFAIK, the clipboard is not a feature of the kernel but of the environment you are running.

Here is a similar issue on StackOverflow:


I don't know about any command-line utilities. Here are some things that I found:

| improve this answer | |
  • I was trying to use the X selection system so that it wouldn't matter whether or not a particular widget set or window manager's libraries were installed. Thank you very much for the question-link by the way...it sort of answers the question that I had been wondering about. It seems that the ability to handle non-(plain)text formats in the clipboard is an extension provided by gnome/gtk or qt/kde. I'll just have to implement it in gtk and live with it. ;) – Matthew Apr 4 '11 at 13:01

More modern versions of xclip do support formatted data. For example, if you have a command that outputs RTF, the following should result in the formatted text being properly placed in your clipboard:

command_outputting_rtf | xclip -selection clipboard -t 'text/rtf' -i

Analogously, if you're dealing with html:

command_outputting_html | xclip -selection clipboard -t 'text/html' -i

Based on: https://unix.stackexchange.com/a/145134/176466

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.