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>

🙂

Ref: http://linuxtidbits.wordpress.com/2008/02/22/command-line-to-clipboard/

2 thoughts on “linux command to copy text to clipboard

Comments are closed.