Sometimes I want to get something into the system clipboard without using a mouse, like wanting the entire contents of a file in the clipboard, but without the odd linebreaks that text editors are prone to inserting all on their own.
I discovered the ‘pbcopy’ and ‘pbpaste’ tools, which are just perfect.
bash $ echo "blah" | pbcopy Now “blah” is in my clipboard. I can
Command-V in any window, and there it is.
I can also manipulate the contents of the clipboard in any script with
bash $ pbpaste | wc -l I just counted the number of lines of
text in the clipboard. Yay!
http://www.commandlinefu.com/commands/view/751/mac-os-x-copy-and-paste-things- to-and-from-the-clipboard-from-the-shell☙ ☙ ☙