Using the clipboard from the Mac OS X Terminal

You can use the clipboard from the directly from the terminal application, Mac OS X gives you two commands:

pbcopy

pbpaste

Naturally pbcopy will copy something on the clipboard and pbpaste will paste something from the clipboard.

For example you might want to save the results of a search on the file system:

# find ./ -name "*.doc" | pbcopy

this command will find for all the .doc documents starting from the current directory and then it will put the result in the clipboard.

if you want to make a text file from the content of the clipboard you can issue the following command:

# pbpaste > pasted.txt

This command will create the file pasted.txt with the content of the clipboard.

For further information issue the following commands:

# man pbcopy

or

# man pbpaste

Gg1

Posted by at August 24, 2010
Filed in category: Bash Tip & Tricks, Mac OS X, and tagged with: , , , ,

2 Responses to Using the clipboard from the Mac OS X Terminal

  1. moonpixel says:

    excellent thanks for this

  2. Jonathan says:

    Good, but I prefer
    find ./ -name "*.doc" > testfile.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

Statistical data collected by Statpress SEOlution (blogcraft).