osbzzq
Last Updated: October 11, 2016
·
18.95K
· jmarizgit
527657 350954588303809 1195162128 n

Copy files to clipboard using command line on OSX

Use "pbcopy" to copy content of file to your clipboard.

For example:

$ pbcopy < file.txt

the command will copy all content from "file.txt" directly on your clipboard.

You can check if the content is there by using the "pbpaste" command:

$ pbpaste

The content of "file.txt" will appear on your terminal window.

If you use other *nix distribution please take a look over xclip or xsel. Take look over this website:

http://jetpackweb.com/blog/2009/09/23/pbcopy-in-ubuntu-command-line-clipboard/

Say Thanks
Respond

4 Responses
Add your response

5279
70e1167dbde5397557b0ec6fabb3d90a

for windows users you can use

to copy from a file

$ cat file > /dev/clipboard

to paste into a file

$ cat /dev/clipboard > file

or to check the contents of the clipboard

$ cat /dev/clipboard

:) enjoy.

over 1 year ago ·
5315
Img 4302

You can also copy anything using pipes:

$ cat file | grep something | pbcopy
$ echo $ENV_VAR | pbcopy
over 1 year ago ·
5325
602452 559499297898 738290963 n

Linux user here: I don't have pbcopy, and I don't see it in Ubuntu's repos. Since Ubuntu is one of the more common Linux distros, I think it's safe to say that this is not common to many unix users.

So where is pbcopy available? OSX?

over 1 year ago ·
5327
527657 350954588303809 1195162128 n
over 1 year ago ·
Filed Under