Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to send the contents of a text file to the OS X clipboard.

Does Mac OS X have a built in way to do this, or will I have write a script to do this myself?

Or in other words, how do I access the clipboard from the command line?

share|improve this question

migrated from Jun 16 '11 at 20:56

This question came from our site for professional and enthusiast programmers.

up vote 5 down vote accepted

Nevermind, figured it out.

 pbcopy < filename

  #copies contents of a text, rtf, or eps file to the clipboard


  #pastes content of clipboard to stdout
share|improve this answer
That's awesome. Where did you find this info, and are there other cool conduits between CLI world and GUI world? – slim Sep 18 '08 at 19:32
@slim Just, for example, google the title of the question – Matteo May 4 '14 at 14:47

Yep, that's the way to go. Of course, you can also pipe output into it, ie, echo "test" | pbcopy.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.