Copy a string to clipboard from Mac OS command line Copy a string to clipboard from Mac OS command line shell shell

Copy a string to clipboard from Mac OS command line


You need to pipe the output of your script to pbcopy

For example:

./somescript.sh | pbcopy


echo 'your-email@example.com' | pbcopy(as @Jonathan Leffler stated above)

Or see the answer for the related question on piping to clipboard on different operating systems:Pipe to/from the clipboard in Bash script