Juicy lil' bytes

Copy to and Paste From the Clipboard on the Mac OSX Command Line

You can access the clipboard from the Mac OSX command line with a set of copy and paste commands.

Mac OSX Copy and Paste Commands

Command Function
pbcopy Copy to Clipboard
pbpaste Paste from Clipboard

Mac OSX Command Line Copy

To add the standard output from any other command to the clipboard, pipe it to the pbcopy command:

curl -L "http://coolsite.com" | pbcopy

and then paste it in your GUI applications wherever you need.

Mac OSX Command Line Paste

To paste text from the clipboard to the standard output stream, use the pbpaste command:


and the clipboard text will be printed out in your terminal window.

If you’d like to do more with it, you can pipe the clipboard data to any other application that accepts the standard input stream. For instance, to create paginated output from a large block of text, you can pipe it to less:

pbpaste | less


Kudos to Chealion on apple.stackexchange.com.