Mac OSX: Copy to clipboard terminal command

To copy the contents of a file to the clipboard is pretty straight forward on a Mac terminal:

cat file.txt | pbcopy

To paste the contents of the clipboard into a file:

pbpaste > file.txt