[HOW TO] Read/Write clipboard from command line

xsel is a program that allows X selection manipulation, and it can also be used to manipulate clipboard contents.

Read clipboard

Open a terminal window and run the command bellow. The -b options tells xsel to operate on the CLIPBOARD selection and the -o is used to write the selection contents to standard output.

xsel -b -o

Write clipboard

Using the -i, xsel reads from the standard input into the selection, so for instance, the output of the echo command can be piped into xsel thus set the clipboard contents. Replace CB_DATA with is a string for clipboard data.

echo CB_DATA | xsel -b -i
Example (write)
echo "Xubuntu Geek" | xsel -b -i

References

xsel manpage

Comments

Popular posts from this blog

[HOW TO] Create QR Codes in Xubuntu 12.04

[FIX] VLC is unable to open the MRL (smb://)

Add items to Xfce Applications Menu