Is there any easy way to implement the copy to clipboard option from the output of a shell script ?
You can use pbcopy which is native for Mac OS.
pbcopy
Try this command:
echo "variable" | pbcopy
it will copy the string "variable" into your clipboard.