Being a Linux user and starting now with Mac, I am constantly looking for equivalent ways to do the same job.

One of those things I need is to copy large amounts of output in the console (terminal window) to the clipboard for later use.

In Linux I use xclip, and in Mac I'll use pbcopy and pbpaste

Copy from terminal window to clipboard

To copy the output of a command to clipboard just enter something like this:

ls -al | pbcopy

Now we have the output of the command ls -al (that is the contents of the current folder) copied to the clipboard, you can now paste it to any other aplication using "command"+v

Paste from clipboard to terminal

If you need to work the other way, just copy something into the clipboard, using the above method or if in any other Mac aplication with "command"+c.

Once you have the contents in the clipboard, paste it using pbpaste

pbpaste > /tmp/somefile.txt


As you see, it is really easy to copy and paste contents to and from the clipboard while working on the terminal window in a Mac.