xclip Does Copy-and-Paste on the Linux Command Line
xclip For Console Copy and Paste
xclip (available as a package for Debian and Ubuntu) enables you to interact with the X clipboard directly from the command-line - without having to use the mouse to cut and paste.
command --arg | xclip
Then go to whichever graphical program you want to paste the input into, and paste with the middle mouse button or the appropriate menu item.
You can also enter the contents of a file straight into xclip:
and again, can then paste that directly wherever you want it.
The -o option enables you to operate it the other way around: output the contents of the clipboard straight onto the command line. So, you could, for example, copy a command line from a web page, then use
to output it. To output to a file, use
xclip -o /path/to/file
Use the -selection switch to use the buffer-cut or one of the other selection options, rather than the clipboard default. You can also hook it up to an X display other than the default one (e.g., if you're logged on as a different user on :!) with
xclip -d localhost:1
Article courtesy of Serverwatch
- 1Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 2Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 3Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 4Linux 4.6 Charred Weasel adds USB 3.1 Support
- 5Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader