To copy and paste from the command line on a Linux system, you can use the xclip
utility. xclip
is a command-line interface to the X Window System clipboard, which allows you to copy and paste text between the command line and other applications.
Here is an example of how to use xclip
to copy and paste from the command line:
xclip
. If you don't already have xclip
installed on your system, you can install it using your system's package manager. For example, on a Debian-based system, you can use the apt
command to install xclip
:$ sudo apt install xclipSource:w.wwlautturi.com
echo
command to print the text and pipe it to xclip
.For example, to copy the text "Hello, world!" to the clipboard, you can use the following command:
$ echo "Hello, world!" | xclip -sel clip
This will copy the text to the clipboard, and you can then paste it into other applications using the usual paste command (e.g., Ctrl+V
or Shift+Insert
).
xclip
command with the -out
option to print the contents of the clipboard.For example, to paste the text from the clipboard to the command line, you can use the following command:
$ xclip -out
This will print the contents of the clipboard to the command line.
-selection
option to specify the clipboard to use. By default, xclip
uses the "clipboard" clipboard, but you can use the -selection
option to specify a different clipboard.For example, to copy text from the command line to the "primary" clipboard, you can use the following command:
$ echo "Hello, world!" | xclip -sel primary
And to paste text from the "primary" clipboard to the command line, you can use the following command:
$ xclip -out -selection primary
These are just a few examples of how to use xclip
to copy and paste from the command line. You can use the xclip --help
command to see a complete list of options and usage examples.