Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm coping file to xclip

cat file.txt | xclip

I'm pasting without problem with

xclip -o

When I want to paste it to Firefox with Ctrl+V it pastes old text (that shouldn't already be in the clipboard).

When I go back to terminal and run xclip -o it pastes the correct text.

Why is there a problem with pasting to Firefox?

share|improve this question
Note that this is useless use of cat. You can also do xclip file.txt according to its man page, and in general you can also redirect input using <, e.g. $some_command < file.txt. – janmoesen Oct 13 '11 at 18:33
up vote 21 down vote accepted

X11 has several available clipboards. By default, xclip places data in the primary selection buffer. To paste it, you use middle-click.

If you want to use Ctrl+v, use xclip -selection clipboard. See man xclip for more information.

There is good information about the different clipboards on freedesktop.org.

share|improve this answer
the command xclip -selection clipboard never ends and I don't have middle button (only touchpad) – xralf Oct 12 '11 at 16:09
My fault, now I understand. – xralf Oct 12 '11 at 16:12
On a side note: I just noticed that xclip's option -f, -filter is a built in tee . It writes to the clipboard and to stdout at the same time. That could come in handy (for something). – Peter.O Oct 13 '11 at 7:34

Copy to your clipboard with:

xclip -sel clip < ~/path/to/file.txt

and then paste CTRL + V wherever you wish to.

share|improve this answer

Add this to to your ~/.bashrc

# now `cclip' can be used when you it to be available to `ctrl-[vxc]'
alias cclip='xclip -selection clipboard'

alternatively, run this:

echo 'alias cclip='"'"'xclip -profile clipboard'"'" >> ~/.bashrc
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.