---
title: "xclip - command line interface to X selections (clipboard)"
description: "xclip reads from standard in and makes the data available as an X selection for pasting into X applications. Practical notes."
url: "https://h3manth.com/scribe/xclip-command-line-interface-to-x-selections-clipboard/"
canonical_url: "https://h3manth.com/scribe/xclip-command-line-interface-to-x-selections-clipboard/"
markdown_url: "https://h3manth.com/scribe/blog/xclip-command-line-interface-to-x-selections-clipboard.md"
publishDate: "2009-07-10T00:00:00.000Z"
author: "Hemanth HM"
category: "cli"
tags: ["linux","bash"]
word_count: 152
reading_time_minutes: 1
x_markdown_tokens: 302
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# xclip - command line interface to X selections (clipboard)

> xclip reads from standard in and makes the data available as an X selection for pasting into X applications. Practical notes.

xclip reads from standard in, or from one or more files, and makes the data available as an X selection for pasting into X applications. Prints current X selection to standard out.

To install:

```bash
sudo apt-get install xclip
```

How to work with xclip - say for example you want an output of a command in your X selection. After running `command | xclip`, you can just middle click your mouse to paste the output or else you may use the -o option: `xclip -o /path/file-name`.

**Examples:**

```bash
# Put your uptime in the X selection. Then middle click in an X application to paste.
uptime | xclip

# Exit after /etc/motd (message of the day) has been pasted 10 times.
# Show how many selection requests (pastes) have been processed.
xclip -loops 10 -verbose /etc/motd

# Put the contents of the selection into a file.
xclip -o > helloworld.c
```
