Note for Linux users

You can setup xsel to behave like this tool - see the aliases section on the xsel cheatsheet.

Installation

This comes installed on macOS.

Usage

$ echo "This is a test" | pbcopy

Read with pbcopy

Copy file to the clipboard.

$ pbcopy < PATH

Or:

$ cat PATH | pbcopy

Output with pbpaste

Print the clipboard contents:

$ pbpaste

Pipe clipboard contents to a command:

$ pbpaste | head

Write clipboard contents to a file:

$ pbpaste > test.txt