Copy shell script output to clipboard

bash, shell

Solution

That may depend on the environment you're using. With Gnome at least (I haven't tried the others but it may work), you can pipe your output as follows:

echo 123 | xclip
echo 123 | xclip -sel clip

The first goes to the mouse clipboard, the second to the "normal" clipboard.

Problem

Is there any easy way to implement the copy to clipboard option from the output of a shell script ?

Original source