2

Simple Question that I just realized would be very useful.

Under Linux (or really any 'nix environment) is it possible from the command line (or by other fashions, but primarily command line) to copy a file to the clipboard? Any example of this working would be appreciated but the best answer would be a general case in which this is possible across multiple 'nix environments (I'm running Fedora 10 atm if that makes any difference).

akdom
  • 123
  • 4

2 Answers2

7

Looks like you want xclip.

Usage:

xclip -t clipboard somefile

or an example using using pipes:

grep "needle" myfile.txt | xclip -t clipboard

Without the -t clipboard the data will go to PRIMARY selection.

Pablo A
  • 169
  • 9
chaos
  • 7,463
  • 4
  • 33
  • 49
4

Are you in X? Or text-only?

If you're in text mode, it's dead simple if you're using screen (which is awesome):

<C-A>:readbuf /path/to/file

To paste:

<C-A>]
MikeyB
  • 38,725
  • 10
  • 102
  • 186