Shell commands to copy to clipboard

The clipboard is an easy way to transfer data from the command line to other tools. Use your system’s “copy to clipboard” command to store a command’s output for pasting into other applications.
(See also my “paste from clipboard” post.)
On macOS, use pbcopy:
$ <command> | pbcopy
On Windows, use clip:
$ <command> | clip
On Linux with Wayland (most distributions), use wl-copy:
$ <command> | wl-copy
On Linux with X11 (typically older distributions), use xclip:
$ <command> | xclip
🤩 Black Friday deal: My books on Django, Git, and GitHub are all 50% off until the end of Cyber Monday (30th November).
One summary email a week, no spam, I pinky promise.
Related posts: