- Published on
Copy and Paste Contents from the CLI with pbcopy and pbpaste
- Authors
- Name
- Ashik Nesin
- @AshikNesin
If you want to automate things in shell, especially copy-paste things from the terminal then pbcopy
and pbpaste
commands might be a good choice for you on MacOS.
With those commands, we can copy paste contents from and to the clipboard easily.
TLDR:
Commmand | Description |
---|---|
pbcopy | Copies the output from the previous command to the clipboard |
pbpaste | Outputs the contents of the clipboard to the standard output (stdout) |
echo "Copy this" | pbcopy # Now your clipboard will have "Copy this"
echo $(pbpaste) # "Copy this" is printed on the terminal
Happy copy-pasting texts!