How can I pipe the output of a bash or shell command to the clip board? [duplicate]
Solution 1:
Install xsel either through the above link or through the terminal:
sudo apt-get install xsel
To copy the output of a command use:
*command* | xsel -ib
An example:
$ drush uli | xsel -ib
You can make it simpler by editing (create it if you don't already have it with touch ~/.bash_aliases
) your ~/.bash_aliases
file.
Add this line to it: alias clipboard = 'xsel -ib'
(you can use any name, not just clipboard
).
Once you've done so you can use: *command* | clipboard
Solution 2:
I use xclip.
Example:
bashscript.sh | xclip -sel clip