Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am able to copy a massive string of text but unable to paste it anywhere without the program crashing.

So, I wonder: How can I fetch it from the clipboard via CLI and save it to a file instead?


share|improve this question
up vote 4 down vote accepted

xclip is the command line interface to X selections (clipboard)

xclip -o > helloworld.c

You may need to modify the command depending on the selection you're using

          specify  which  X  selection  to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or
          "clipboard" for XA_CLIPBOARD
share|improve this answer
+1 for xclip - so useful! – Brandon Bertelsen Dec 10 '12 at 23:40
Thanks! I've used this before but I couldn't remember the command for the life of me! – Nathan J. Brauer Dec 12 '12 at 21:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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