Ubuntu – A command-line clipboard copy and paste utility

clipboardcommand linesoftware-recommendation

In Windows I used command-line clipboard copy-and-paste utilities…

  • pclip.exe and gclip.exe

These were UnixUtils ports for Windows (but they only handled plain text). There were a couple of other native Windows utilities which could write/extract any format.

I've looked for something similar in Synaptic Package Manager, but I can't find anything.

Is there something there, that I've missed? … or maybe this is available in Bash scripting?

The type of utility I'd like will be able to read/write via std-in/std-out or file-in/file-out, and handle Unicode, Rich Text Format, picture, etc. clipboard formats…

NB: I'm not after a clipboard manager.

Best Answer


I am using xsel Install xsel, but I am only using it with plain text and unicode text.

xsel can copy and paste to three different "clipboards".

By default, it uses the X Window System primary selection, which is basically whatever is currently in selection. The X Window System also has a secondary selection (which isn't used much), and a clipboard selection. You're probably looking for the clipboard selection, since that's what the desktop environment (e.g. Gnome, KDE, XFCE) uses for its clipboard. To use that with xsel:

xsel --clipboard < new-clipboard-contents.txt
xsel --clipboard > current-clipboard-contents.txt