Copy file contents to the clipboard in Mac OS X Terminal

Mac OS X Terminal app icon

Here is how to copy the contents of a file to your clipboard while you are in Terminal on Mac OS X.

pbcopy < file.txt

To confirm that the contents were copied to the clipboard, enter in:

pbpaste

 

 

pbcopy

pbcopy takes the standard input and copies it into the clipboard (pasteboard). The input is copied as plain text, unless you are referencing an EPS or RTF file.

Sidenote: pb stands for “pasteboard”: Apple’s nomenclature for the clipboard on Mac OS X. Pasteboard has different connotations in the context of iOS apps. You can find out more about pasteboards here.

 

pbpaste

pbpaste removes the data from the pasteboard and prints it to the standard output.

 

 

Did you find this helpful and think it would be beneficial for someone else? Share now!

Leave a Reply

Your email address will not be published. Required fields are marked *