LinuxCommandLibrary

xclip

TLDR

Copy output to primary selection

$ echo 123 | xclip
copy
Copy to system clipboard
$ echo 123 | xclip -selection clipboard
copy
Copy file contents to clipboard
$ xclip -selection clipboard input.txt
copy
Copy image to clipboard
$ xclip -selection clipboard -target image/png image.png
copy
Copy from user input
$ xclip -i
copy
Paste from primary selection
$ xclip -o
copy
Paste from clipboard
$ xclip -o -selection clipboard
copy

SYNOPSIS

xclip [-i|-o] [-selection sel] [-target type] [file...]

DESCRIPTION

xclip is an X11 clipboard manipulation tool. It can read data from standard input or files and write it to any X selection (primary, secondary, or clipboard), or output selection contents to stdout.

PARAMETERS

-i, -in

Read from stdin or files (default mode)
-o, -out
Write selection to stdout
-se, -selection SELECTION
Specify selection: primary, secondary, or clipboard
-t, -target TYPE
Specify MIME target type (e.g., image/png, text/html)
-d, -display DISPLAY
X display to connect to
-l, -loops N
Number of paste requests to serve before exiting
-f, -filter
Print input to stdout while copying
-q, -quiet
Suppress informational output
-v, -verbose
Print extra information
-silent
Fork into background (used with -loops)

X11 SELECTIONS

primary: Middle-click paste (highlight to copy)
secondary: Rarely used secondary selection
clipboard: Ctrl+C/Ctrl+V clipboard

CAVEATS

Data is only available while xclip is running (unless using -loops or -silent). For persistent clipboard storage, use a clipboard manager. The default selection is primary, not clipboard.

HISTORY

xclip was written by Kim Saunders as a command-line interface to X11 selections. It provides scriptable clipboard access without GUI dependencies.

SEE ALSO

xsel(1), wl-copy(1), wl-paste(1)

Copied to clipboard