Copy shell script output to clipboard
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.
You can use pbcopy
which is native for Mac OS.
Try this command:
echo "variable" | pbcopy
it will copy the string "variable" into your clipboard.