Copy a file's contents to the clipboard on Mac
Send any text file (or command output) straight to the clipboard from Terminal.
01Command
$ pbcopy < ~/Documents/notes.txt02What it does
pbcopy reads standard input and loads it into the macOS pasteboard, exactly as if you had selected the text and pressed Cmd+C. The < redirect feeds it a file; a pipe feeds it command output, e.g. cat log.txt | pbcopy or git diff | pbcopy. Its counterpart pbpaste prints the clipboard to the terminal. Pairs beautifully with SSH: cat key.pub | pbcopy grabs a public key from a remote server.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- macOS pbcopy / pbpaste command referenceEvidence: pbcopy reads standard input and places it on the system pasteboard (clipboard).
Last verified: 2026-09-16 · Category: Developer
06Related solutions
Point macOS screen captures at any folder you choose instead of the desktop.
Grab any file from the web straight into the current folder — no browser needed.
List the biggest files in your home folder that are eating disk space.