Save last "copy" from clipboard to file

6,505

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
Share:
6,505

Related videos on Youtube

Nathan J.B.
Author by

Nathan J.B.

Updated on September 18, 2022

Comments

  • Nathan J.B.
    Nathan J.B. over 1 year

    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!

  • Nathan J.B.
    Nathan J.B. over 11 years
    Thanks! I've used this before but I couldn't remember the command for the life of me!
  • Pablo Bianchi
    Pablo Bianchi over 6 years
    For images you might need -t image/png.