Save last "copy" from clipboard to file

Solution 1:

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