Copy file contents to the clipboard in Linux terminal
You can do the following that will directly copy the content of id_rsa.pub to clipboard:
pbcopy < ~/.ssh/id_rsa.pub
xclip -sel c < input_file
will copy the contents of input_file
to clipboard. xclip
requires installation. To install
sudo apt install xclip
-sel
stands for -selection
. c
is for clipboard
. Interchangeable.
Capable of much more, I advise reading its man page.
There is also xsel
. This answer on Unix SE gives a very thorough answer to this exact question.
If you're copying from terminal (like if you use the cat command already posted), highlight the key details and use Ctrl + Shift + C. This should put it on your clipboard. You can also right click and select 'copy' from terminal.
xclip -selection clipboard -i < fileName
copies the content of file into clipboard