fettig.net

A useful OS X command: pbcopy

Posted by Abe on Monday, June 25, 2007 @ 11:44 pm

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. xclip is a similar utility for X Window System.

    Comment by Seo Sanghyeon — June 26, 2007 @ 1:28 am

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

    Comment by Marius Gedminas — June 26, 2007 @ 6:08 am

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

    Comment by Matthew — June 26, 2007 @ 9:26 am

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

    Comment by Abe — June 29, 2007 @ 9:55 pm

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.