Is is possible to put into clipboard the result of a shell command? Is is possible to put into clipboard the result of a shell command? unix unix

Is is possible to put into clipboard the result of a shell command?


Depends. Linux, Mac or Windows?

The mac has the commands pbcopy and pbpaste to copy and paste something from the clipboard.

Copy example (mac):

echo $PATH | pbcopy

Paste Example (mac):

echo "$(pbpaste -Prefer txt)"

Linux uses X which has multiple copy-paste buffers (somewhat akin to the clipboard, but a little more involved).

You can use a little application like XSel to copy/paste, The command would be used in the same form as the pbcopy/pbpaste

Copy:

echo $PATH | xsel --clipboard

'paste':

echo "$(xsel --output --clipboard)"

For windows, you can use an app like clip, which allows the same copy/paste functionality

Copy:

set %PATH% | clip

I generally use Linux/Unix so I don't have the equivalent for pasting from the clipboard on Windows.