I've found myself needing to do this a couple of times lately and wondered if there was a way to do this in the OS already. Failing that, I've got a pretty good idea of how to write a script to do it, I just need to know how to access the clipboard in os x.

link|improve this question

80% accept rate
feedback

migrated from stackoverflow.com Jun 16 '11 at 20:56

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

2 Answers

up vote 4 down vote accepted

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
link|improve this answer
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 '08 at 19:32
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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