pbcopy
copies standard input to the macOS clipboard
TLDR
Copy text to clipboard
$ echo "[text]" | pbcopy
Copy file contentscopy
$ pbcopy < [file.txt]
Copy command outputcopy
$ ls -la | pbcopy
Paste from clipboardcopy
$ pbpaste
Paste to filecopy
$ pbpaste > [file.txt]
copy
SYNOPSIS
pbcopy [options]pbpaste [options]
DESCRIPTION
pbcopy copies standard input to the macOS clipboard (pasteboard). Its companion pbpaste outputs clipboard contents to standard output.These tools integrate the command line with the graphical clipboard, enabling scripted clipboard operations.
PARAMETERS
-pboard name
Pasteboard name (general, ruler, find, font).-Prefer type
Preferred data type (txt, rtf, ps).
USAGE EXAMPLES
Copy output and paste elsewhere:
$ cat file.txt | pbcopy
# Cmd+V in any application
Process clipboard contents:# Cmd+V in any application
copy
$ pbpaste | grep pattern
copy
CAVEATS
macOS only. Rich text may not copy as expected. Binary data needs careful handling. Pasteboard changes affect system clipboard.
HISTORY
pbcopy and pbpaste are macOS utilities provided by Apple. They have been part of macOS since early versions, providing command-line access to the system pasteboard (clipboard).