fettig.netBlog2007 → A useful OS X command: pbcopy

A useful OS X command: pbcopy

Today I learned about the pbcopy command in OS X. It lets you copy text to your clipboard from the command line. This means you can (among other things) copy the contents of a file on a remote server into your clipboard, ready for pasting:

ssh myserver -x "cat myfile" | pbcopy

Believe it or not, this actually came in very handy for a debugging task I was working on. There’s also a pbpaste command, which prints the current clipboard contents to stdout.

4 Comments

  1. Seo Sanghyeon says:

    xclip is a similar utility for X Window System.

  2. The Linux equivalent is ‘xsel’. It’s very handy sometimes.

  3. Matthew says:

    xclip works similarly if you should find yourself in a non-OSX environment.

  4. Abe says:

    thanks guys. (and apologies to Seo and Marius, for taking so long to approve your comments)