Mac Terminal tip: pbcopy and pbpaste

Just found two helpful programs in OS X; pbcopy and pbpaste (man page). They let you write and read from the OS X clipboard and allow you do to things like:

$ cat file.txt | pbcopy

That’s a lot faster than opening the file, selecting everything, and copying it!

$ pbpaste > example.css

Quicker than firing up emacs/TextMate/whatever.

Of course you can even do fancier things like:

$ tail -n 10 /var/log/messages | pbcopy

So good!