How to pipe/dump clipboard contents to a file?

How to pipe clipboard contents to a file?

You can do it using xsel. Type in terminal to install it,

sudo apt-get install xsel

To put the contents of the clipboard/Ctrl+C to a file use,

xsel -b > some.txt

I am putting the clipboard contents to the some.txt file.

Done.

Copy file content/string to clipboard

You can go through this answer by Radu Rădeanu which described how you can copy file content/string from a terminal to clipboard that can be pasted using Ctrl+V


You can also use xclip (install with sudo apt-get install xclip) like so:

xclip -selection clipboard -o > clipboard.txt

which will put the clipboard into clipboard.txt in the working folder.