December 9, 2022

Copy the content of a file to the clipboard from the command line

Run:

$ xclip file.txt

Sometimes, you might need to copy to another selection, for instance:

$ xclip -selection clipboard file.txt

Check $ man xclip to see other selections.

If you need to install xclip run:

$ sudo apt install xclip

What is xclip?

From xclip’s repository:

xclip is a command line utility that is designed to run on any system with an X11 implementation. It provides an interface to X selections (“the clipboard”) from the command line. It can read data from standard in or a file and place it in an X selection for pasting into other X applications. xclip can also print an X selection to standard out, which can then be redirected to a file or another program.

xclip is licensed under GNU General Public License v2.0.

You can run $ man xclip for more informations, options, examples, etc.


personal computing gnu linux command-line interface (cli) xclip

No affiliates, No (Google) Analytics. © 2016-2023 yctct.com. Content is licensed under CC BY-NC-SA 4.0 .