Possible Duplicate:
Copy file to xclip and paste to Firefox

I would use the following command to copy the output of uptime to the clipboard:

uptime | xclip

Then I can paste the copied uptime to the console by clicking the middle button of mouse. But when I go to an application like "gedit", there is no Paste option available there. How can I copy a text into clipboard so that it could be pasted onto something like "gedit"?

  • Does middle click not work in gedit? – jw013 Jun 30 '12 at 14:24
  • @jw013 No it doesn't. – Meysam Jun 30 '12 at 17:05

I was having a similar issue until I did the following (on Ubuntu):

uptime | xclip -selection c

From the man pages:

             specify  which X selection to use, options are "primary" to
             use XA_PRIMARY (default), "secondary" for  XA_SECONDARY  or
             "clipboard" for XA_CLIPBOARD
  • 1
    Note that the shorthand uptime | xclip -se c would also do, since xclip admits abbreviations provided they don't conflict with valid options and keywords (-silent and -selection, for example) – XavierStuvw Jul 16 '18 at 8:32

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