pbpaste and pbcopy in Mac OS X (copy/paste on the command line)
Although the OS X shell is very powerful, some useful commands are not very known. This is specially true for pbcopy and pbpaste, which can be used for several different automation operations or just copying/pasting contents from stdin/stdout.
pbcopy
Copy contents from standard input (stdin) into the clipboard.
Example:
date | pbcopy
The current date is copied to the clipboard. Check it pressing ⌘+v (command+v on a Mac) in a text editor - or even in the terminal window - to paste the current date to the clipboard.
pbpaste
Pastes the content from the clipboard to standard output (stdout).
Example:
echo `pbpaste`
This will echo the contents of the clipboard. If you have used the pbcopy example above, the current date will be displayed.
Reference:
[PBCOPY(1)] (https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pbcopy.1.html)