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/
Written by Mariz Melo
Related protips
4 Responses
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.
You can also copy anything using pipes:
$ cat file | grep something | pbcopy
$ echo $ENV_VAR | pbcopy
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?
@spencerwi you are right, here is what I found for Ubuntu:
http://jetpackweb.com/blog/2009/09/23/pbcopy-in-ubuntu-command-line-clipboard/