Last Updated: February 25, 2016
·
2.728K
· jacaetevha

pbcopy & pbpaste

I love pbcopy and pbpaste on my Macs! I use them all the time. From the man page, they "provide copying and pasting to the pasteboard (the Clipboard) from the command line." You can even copy Encapsulated PostScript and RTF using these commands.

Linux? Well, if you install the XSel utility you can have these commands there also via Shell aliasing (plain text copy/paste only):

alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'

Update (2012-11-18): You can also use the xclip utility (thanks to passcod for the suggestion):

alias pbcopy='xclip -in -selection c'
alias pbpaste='xclip -out -selection c'

2 Responses
Add your response

On Linux it's typically xclip that's used:

xclip | cat > paste/file
cat copy/file | xclip
over 1 year ago ·

xclip is certainly an alternative, Looking at the popularity contest statistics for the two, about 29% still use xsel though. I'll update my post to include xclip information.

over 1 year ago ·