Mac OS X provides two utilities that make it possible to manipulate the clipboard in the Terminal:
pbcopy puts the data it receives via standard input into the clipboard.
echo "Hello, World!" | pbcopy pbcopy < aFile
pbpaste does the opposite. It ouputs the clipboard to the standard output.
pbpaste pbpaste > anotherFile
It is possible to select the preferred format for the clipboard data using the
Both commands also accept the
Usage: pbcopy [-help] Usage: pbpaste [-help] [-Prefer rtf|ps|ascii]