21

I need to directly copy the terminal stdout to the clipboard on Mac. How would I do this?

Example:

echo sometext | copy_to_clipboard

or

echo sometext > /private/clipboard.txt

1
27

Use pbcopy:

echo foo | pbcopy

Also see man pbcopy for info on it and pbpaste.

1
  • 1
    Or for a file, e.g. rsa key use pbcopy < ~/.ssh/id_rsa.pub Dec 1 '18 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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