Use the clipboard in the terminal

Jun 27, '01 10:12:16PM

Contributed by: robg

Over on the MacNN forums, "kvm_mkdb" posted a couple of useful commands regarding the Mac OS clipboard. If you're in the terminal, and want the output of a command on the clipboard, you can easily get it. For example, to dump a detailed directory list to the clipboard, just type:

ls -al | pbcopy #
You can then paste the contents of the clipboard using pbpaste:
pbpaste > somefile #
This would send the clipboard contents into "somefile". Of course, that's not a great example, as you could have just sent the directory list to the file in the first place (ls -al > somefile). However, it's more useful if you want to paste into a GUI-based application such as Word or BBedit. No more mouse selection required; simply use pbcopy, switch to the GUI app, and hit command-V.

I can't find a 'man' page or help file for either of these commands - anyone know if there are more options available?

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20010627221216167