3

Is it possible to redirect the output of your terminal in linux to the clipboard? Right now I am using Ubuntu 9.10 and I simply right click and "copy" the selected text. It would be a lot easier if I could go like this...

grep sometext myfile || clipboard
benstpierre
  • 265
  • 1
  • 3
  • 7

2 Answers2

6

The xclip package will do this. Another similar tool that is also frequently useful is pastebinit.

Usage is simple just do something like cat /etc/passwd | xclip.

It is also possible, to take the contents of the clipboard and use it with a command like xclip -out | grep 'foo'.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
2

The command doesn't work just this way:

ls | xclip

You should use this variant to make it work:

ls | xclip -selection clipboard

hmm... rather long for such an easy task...

INDR
  • 21
  • 1