pbpaste Command
What is the pbpaste Command?
The pbpaste
command is a powerful utility found on macOS and other Unix-like systems that allows you to send the contents of the system's clipboard to standard output. This makes it incredibly useful for scripting and automating tasks that involve copying and pasting text between applications and the command line.
How to Use pbpaste
The basic usage of pbpaste
is straightforward. When executed without any arguments, it prints whatever is currently in your clipboard to your terminal.
Examples of pbpaste Usage
Here are some common ways to use the pbpaste
command:
1. Writing Clipboard Contents to a File
You can redirect the output of pbpaste
to a file, effectively saving your clipboard's content into a document.
# pbpaste
# Send the contents of the clipboard to standard output.
# Write the contents of the clipboard to a file:
pbpaste > output.txt
2. Piping Clipboard Contents to Another Command
pbpaste
is often used in conjunction with other command-line tools via pipes. This allows you to process the clipboard content directly.
# Use the contents of the clipboard as input to a command:
pbpaste | grep "specific_keyword"
Related Commands
The counterpart to pbpaste
is pbcopy
, which takes standard input and places it into the clipboard. Together, they form a robust way to manage clipboard data from the command line.