xclip in Ubuntu
Introduction
To save time when working with files and when processing command output you can install
xclip
and redirect the output straight to the clipboard.
This saves you from wasting time on selecting text and copying and pasting it.
Installation
sudo apt install xclip
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: xclip 0 upgraded, 1 newly installed, 0 to remove and 41 not upgraded. Need to get 18.4 kB of archives. After this operation, 60.4 kB of additional disk space will be used. Get:1 http://fi.archive.ubuntu.com/ubuntu focal/universe amd64 xclip amd64 0.13-1 [18.4 kB] Fetched 18.4 kB in 0s (162 kB/s) Selecting previously unselected package xclip. (Reading database ... 441022 files and directories currently installed.) Preparing to unpack .../xclip_0.13-1_amd64.deb ... Unpacking xclip (0.13-1) ... Setting up xclip (0.13-1) ... Processing triggers for man-db (2.9.1-1) ...
A file to the clipboard
Using the example of the SSH certificate for GitLab
xclip -sel clip < ~/.ssh/gitlab_com_rsa.pub
Command output to the clipboard
The syntax is as follows
COMMAND | xclip
For example
ls | xclip
You can paste the result by pressing the middle mouse button.
Article author: Andrei Olegovich