Save the clipboard to a file with pbpaste

pbpaste writes the current clipboard text to standard output, which makes redirecting a copied snippet into a file a one-liner — the often-forgotten inverse of pbcopy.

macOSpbpasteclipboardLow risk
Run `pbpaste > clipboard.txt` to dump the clipboard contents into a file, or pipe it into any command such as `pbpaste | wc -l`.

01Command

Command
$ pbpaste > clipboard.txt
pbpaste | wc -l

02What it does

Because pbpaste emits plain text on stdout, it composes with grep, wc, sed, and file redirection just like a file read. Only the text flavor of the clipboard is captured; rich formatting is stripped, which is exactly what you want when turning copied web text into clean plain-text files.

03Risk

RiskLow risk
!Warning: Redirection replaces the target file without asking; use `pbpaste >> file` to append instead of overwriting.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Files & Folders