Paste data from the clipboard to STDOUT.
Syntax pbpaste [-pboard {general | ruler | find | font}] [-Prefer {ascii | rtf | ps}] Key -pboard Specify a pasteboard to copy to. By default the general pasteboard. -Prefer Specify the type of data to look for in the pasteboard. (pbpaste normally looks first for ASCII data) In any case, pbpaste looks for the other formats if the preferred one is not found.
pbpaste will remove data from the clipboard/pasteboard and write it to the standard output.
It normally looks first for ASCII data in the clipboard and writes that to the standard output; if no ASCII data is in the pasteboard it looks for Encapsulated PostScript; if no EPS if present
it looks for Rich Text.
If none of those types is present in the pasteboard, pbpaste produces no output.
Examples
Save the clipboard to a file in the users home folder:
$ pbpaste > ~/ss64.txt
Save the clipboard to the END a file in the users home folder:
$ pbpaste >> ~/ss64.txt
Replace spaces in the clipboard text with %20
$ pbpaste | sed 's/ /%20/g' | pbcopy
Replace commas (from CSV data) in the clipboard text with tabs (as recognised by Apple Numbers). To type this command in macOS you will need to replace the \t with a literal tab character: type Ctrl+V and then hit Tab.
$ pbpaste | sed "s/,/\t/g" | pbcopy
Look first for RTF:
$ pbpaste -Prefer RTF
Replace the current contents of the clipboard with a base64 encoded version:
$ pbpaste | base64 | pbcopy
“Failure is not fatal, but failure to change might be” ~ John Wooden
Related macOS commands:
pbcopy - Copy data to the clipboard
printenv - Print environment variables