# xclip on Ubuntu
* refference:[How to Copy Any Text To Clipboard From Terminal In Ubuntu?](http://sandipbgt.com/2015/10/22/copy-text-to-clipboard-from-terminal-in-ubuntu/)
## Introduce the xclip
* xclip is a tool on Ubuntu
## Installing xclip
```linux
$sudo apt-get install xclip
```
## Using xclip
### Coppy the command output
* To copy the output of a command into the clipboard, pipe the command into xclip as below:
> [color=#d82b8d]"pipe" the "|" symbol on a computer keyboard
* Long version
```linux
$ls -la | xclip -selection clipboard
```
* Short version
```linux
$ls -la | xclip -sel clip
```
* This puts the output of ls -la command into the clipboard, and you can now paste the output into any other program (eg. a text editor) with Ctrl + V outside terminal and Ctrl + Shift + V inside terminal.
---
### Copy the contents of a file
* To copy the contents of a file (eg. /etc/apt/sources.list) into the clipboard:
* Long version
```linux
$ xclip -selection clipboard -in /etc/apt/sources.list
```
* Short version
```linux
$xclip -sel clip -i /etc/apt/sources.list
```
---
### Print the contents of the clipboard
* Long version
```linux
$xclip -selection clipboard -out
```
* Short version
```linux
$xclip -sel clip -o
```
---
### Save the contents of the clipboard to a file
* Long version
```linux
$xclip -selection clipboard -out > ~/myfile.txt
```
* Short version
```linux
$xclip -sel clip -o > ~/myfile.txt
```