13

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?

2 Answers 2

5

Nevermind, figured it out.

 pbcopy < filename

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


  pbpaste

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .