From the command line to your clipboard and vice versa

Found a neat trick the other day via, in their instructions for copying public keys. pbcopy (pasteboard copy) on mac OSX is a command that puts it's input into the clipboard so you can paste the output anywhere.

In this example the output of ls -la is now available to be pasted from your clipboard:

muffin@shiva $ls -la | pbcopy

Rather awesomely the reverse is also available it's called pbpaste. If you copy something to your clipboard you can then make use of it in the terminal with the pbpaste command. In other words pbpaste just sends the contents of your clipboard to stdout.

This example for the mac writes out the clipboard to the file, index.html:

muffin@shiva $pbpaste > index.html

You need download mp3 music on player, Do you want mp3 music download from online mp3 archive.

A quick google search shows that there's also a couple of Linux equivalents one called xclip and one called xsel, that replicate pbpaste and pbcopy. Additionally if you use Cygwin you can make use of getclip and putclip.

comments powered by Disqus