Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy shell script output to clipboard

Tags:

bash

shell

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

like image 461
Vamsi Krishna B Avatar asked Oct 26 '10 12:10

Vamsi Krishna B


People also ask

How do I copy output command in Linux?

PRIMARY: The PRIMARY selection is conventionally used to implement copying and pasting via the middle mouse button. xclip command use this by default. So you need to hit middle button to paste data. SECONDARY: This is less frequently used by X application.

How do I copy text to clipboard in Linux?

Ctrl+Shift+C and Ctrl+Shift+V If you highlight text in the terminal window with your mouse and hit Ctrl+Shift+C you'll copy that text into a clipboard buffer. You can use Ctrl+Shift+V to paste the copied text into the same terminal window, or into another terminal window.


2 Answers

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.

like image 104
paxdiablo Avatar answered Sep 22 '22 03:09

paxdiablo


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.

like image 31
Mau Avatar answered Sep 20 '22 03:09

Mau