Search

Top Posts

Comments

  • ZAYIFLAMA YOLLARI: Zayıflama Yolları, diyet listesi,rejim
  • Dan: You’d definitely need a microphone, mic stand and usb audio interface for a start!
  • Sepp: Mac OS X comes with an even more powerful Firewall than the one in the system preferences. Open up the Terminal...
  • jeffcard: Nice guide, thanks for sharing, here is a step by step guide regarding how to convert DVD, video and audio,...
  • James: Well, it hasn’t crashed on me yet, and I’ve been using it for at least 2 months now…

Categories

Recent Posts


Access the clipboard from the command line

terminal-icon-512x5122 With the pbcopy and pbpaste commands, you can access your Mac OS X clipboard directly through the Terminal. Yes, that means you can access what you copied in a GUI app and use it in the command line seamlessly, and vice versa. Here’s an introduction on how to use both copy and paste from the command line:

pbcopy – as you might imagine, pbcopy is how you can copy things from the command line. The best way to use it is by piping something to it, for example:

ls -lha |pbcopy

This will pipe the results of ls -lha into your clipboard, which you can now access using the pbpaste command.

pbpaste – pbpaste is how you dump the contents of the clipboard. If you just want to see what’s in the clipboard, simply type pbpaste and you’ll see whatever is stored. If you used the above ls -lha|pbcopy command youll see the results of that now. You can also easily store the contents of the clipboard into a file by using pbpaste, as follows:

pbpaste > clipboard.txt

Now you’ll have the document clipboard.txt with the contents of your clipboard. You can double-check this by opening it in any text editor, or by typing cat clipboard.txt to see the contents.

pbcopy and pbpaste are a lot more powerful than the above examples though. Here’s how to use pbpaste to send the contents of your clipboard to another machine, by piping the output through an ssh connection into a file named myclipboard.txt on the remote machine:

pbpaste | ssh username@host 'cat > ~/myclipboard.txt'

Nice huh?

Posted by: Bill Ellis

Share

Save big on Mac Deals from Amazon.com

Comments:

Comments: 3

Comment from Moschos
Time: December 9, 2009, 3:47 pm

Really cool, didn’t know it existed on my MACs terminal. Great !!

Comment from warmz
Time: December 9, 2009, 4:23 pm

[Quote] Nice huh? [/Quote]

Beautiful .. terminal heaven!

:)

Pingback from links for 2010-02-01 « Blarney Fellow
Time: February 1, 2010, 6:32 pm

[...] Access the clipboard from the command line – OS X Daily (tags: osx howto cli) [...]

Write a comment






December 9th, 2009