linux command to copy text to clipboard

Install xclip

sudo apt-get install xclip

Copy a string to clipboard

echo -n 'I will be copied to the clipboard!' | xclip -selection c

Use Control+Shift+V to paste the copied string to terminal!

Copy texts from a file to clipboard

xclip -in -selection c <filename>

Paste clipboard contents to a file

xclip -out -selection c <filename>