Copying Console Text to the Clipboard
I created a new computer work flow associated with a hobby. I wrote a shell script that would be launched only manually. I designed the script to display important information. That was fine but being a lazy admin I wanted a specific string in that output to be copied to the desktop clipboard.
Searching the web revealed two common tools,
My initial efforts did not copy the string to the clipboard. Eventually the following script snippet succeeded:
echo -n “$STRING” | xclip -selection clipboard
-n option ensures no annoying line feeds are part of the clipboard content.