Hemanth's Scribes

cli

xclip - command line interface to X selections (clipboard)

Author Photo

Hemanth HM

Thumbnail

xclip reads from standard in, or from one or more files, and makes the data available as an X selection for pasting into X applications. Prints current X selection to standard out.

To install:

sudo apt-get install xclip

How to work with xclip - say for example you want an output of a command in your X selection. After running command | xclip, you can just middle click your mouse to paste the output or else you may use the -o option: xclip -o /path/file-name.

Examples:

# Put your uptime in the X selection. Then middle click in an X application to paste.
uptime | xclip

# Exit after /etc/motd (message of the day) has been pasted 10 times.
# Show how many selection requests (pastes) have been processed.
xclip -loops 10 -verbose /etc/motd

# Put the contents of the selection into a file.
xclip -o > helloworld.c
#linux#bash
Author Photo

About Hemanth HM

Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.