Ever tried copying a huge chunk of text from Terminal, only to end up highlighting half the window? Your Mac has a much better way of doing it.
If you've ever used Terminal to troubleshoot a problem, check your Mac's configuration or run a diagnostic command, you'll know that getting the results into an email or document isn't always particularly elegant. You run a command, Terminal displays several lines of information, and then comes the awkward part: selecting everything with your mouse without accidentally missing a line.
Well, here's another little macOS trick worth knowing. It's called pbcopy, and it's already built into your Mac.
Meet pbcopy
The pbcopy command takes text and places it directly onto your Mac's clipboard, ready to paste into another application.
Let's start with something simple.
Open Terminal (Applications → Utilities → Terminal) and enter:
sw_versYour Mac will display its operating system name, version and build number.
That's useful information when troubleshooting, but what if you want to send it to someone?
Instead of highlighting the results, try this:
sw_vers | pbcopyNothing appears to happen. There's no confirmation message or fancy animation.
But open Notes, Mail or any text editor and press Command + V.
There's your macOS version information, copied perfectly.
What's that funny vertical line?
The character between the commands is called a pipe, represented by |.
Think of it as a little conveyor belt.
The first command produces some information, and the pipe passes that information directly to the next command. In our example, sw_vers gathers your Mac's version details, while pbcopy places them onto the clipboard. It's a surprisingly useful combination.
Copy a list of files
Here's another example.
Let's say you're working inside a folder in Terminal and want to share a list of its contents.
Enter:
ls -1 | pbcopyThis copies a list of filenames from your current directory.
You can then paste that list into an email, a document or a message without manually selecting anything.
And here's the clever bit: pbpaste
Apple also includes a companion command called pbpaste.
As you've probably guessed, it works in reverse.
Copy some ordinary text from Safari, Notes or another application, then open Terminal and type:
pbpasteThe contents of your clipboard appear directly in Terminal.
It's a useful way to check exactly what you've copied, particularly when working with long commands or text.
Just be careful with sensitive information. Anything you copy to your clipboard can potentially be pasted elsewhere, so avoid casually copying passwords or confidential details.
The Apple Geek verdict
This is another of those tiny macOS features that makes you wonder why you haven't been using it for years.
No extra software, no complicated setup and certainly no subscription. Just two little commands that make working between Terminal and your everyday Mac applications that bit easier. And once you've discovered pipes, you'll realise how many other useful Terminal tricks are waiting to be explored.
