Ubuntu – Save last “copy” from clipboard to file

clipboardclipboard-managercommand line

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?

Thanks!

Best Answer

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

   -selection
          specify  which  X  selection  to use, options are "primary" to use XA_PRIMARY (default), "secondary" for XA_SECONDARY or
          "clipboard" for XA_CLIPBOARD